Click here to Skip to main content
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
Your Filters
0 Sergey Alexandrovich Kryukov 515
1 OriginalGriff 498
2 Abhinav S 305
3 sanket saxena 295
4 thatraja 235
0 Sergey Alexandrovich Kryukov 8,482
1 OriginalGriff 4,830
2 Peter Leow 3,794
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107

Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid