Click here to Skip to main content
11,704,768 members (52,258 online)
Rate this: bad
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 2: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 at 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 at 26-Oct-12 8:39am
please tell me how to do..??
Ambesha at 26-Oct-12 8:48am
update my solution please refer. accept the solution and rate the article if relevent
sinhasourabh at 26-Oct-12 8:52am
Why you need a service ? Service runs all the time and will use memory unneccessaryly.
Ambesha at 26-Oct-12 8:54am
user want continues and automated process :)
PRASHANT KUMAR LAL at 26-Oct-12 8:56am
agree with Ambesha, if you have any idea then tell us.. my 5 to Ambesha
sinhasourabh at 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
0 Sergey Alexandrovich Kryukov 658
1 OriginalGriff 485
2 Andy Lanng 275
3 CPallini 242
4 Maciej Los 225
0 OriginalGriff 8,864
1 Sergey Alexandrovich Kryukov 8,245
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2015
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