Click here to Skip to main content
12,757,627 members (37,128 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
Hi all

please tell me how to write code to backup a file/folder from source to destination at a specific date every week...

and if the system in shut down then also it should run as a backup process.
Posted 26-Oct-12 3:16am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Well This could be very easy .

You can use the following code

string sourceFolder = @"c:\update\files";
string outputFolder = @"D:\weeklybackup\"+Convert.ToString(DateTime.Today);
// Code to create outputfolder.
new Microsoft.VisualBasic.Devices.Computer().
    FileSystem.CopyDirectory( sourceFolder, outputFolder );

I always prefer This code over Directory.Move Method because FileSystem.CopyDirectory takes care of all folder,subfiloder and files.

Now after building / compling your code. Dont write a service. Simply add your exe to schedule tasks in your server. I hope u know what are schedule task and how they work.
Menon Santosh 16-Nov-12 1:01am
useful code but need some changes in code, any way my +5 for its simplicity
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

snehasish nandy 26-Oct-12 8:39am
please tell me how to do..??
Ambesha 26-Oct-12 8:48am
update my solution please refer. accept the solution and rate the article if relevent
sinhasourabh 26-Oct-12 8:52am
Why you need a service ? Service runs all the time and will use memory unneccessaryly.
Ambesha 26-Oct-12 8:54am
user want continues and automated process :)
PRASHANT KUMAR LAL 26-Oct-12 8:56am
agree with Ambesha, if you have any idea then tell us.. my 5 to Ambesha
sinhasourabh 26-Oct-12 9:10am
I didn't found these two words in the question ... 'continues and automated' where as he has mentioned : 'at a specific date every week...' I guess there is some misunderstanding. prashant : I have already shared my idea see solution 2.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100