Click here to Skip to main content
Rate this: bad
good
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
good
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.
  Permalink  
v2
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v3
Comments
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 DamithSL 405
1 OriginalGriff 245
2 Sergey Alexandrovich Kryukov 207
3 Peter Leow 185
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,460
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
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