|
-
March 13th, 2006, 08:24 AM
#1
Back up of modified files
Hi all,
There are certain files (like doc, txt etc.) in a directory. I want to make an application which creates a back up of the files as soon as it has been closed after modification.
How can i approach that? Kindly Guide.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 13th, 2006, 08:30 AM
#2
Re: Back up of modified files
Call CopyFile to copy the original file in a new one before saving the modifications.
-
March 13th, 2006, 08:39 AM
#3
Re: Back up of modified files
This function will help to be notified of modification: FindFirstChangeNotification()
Please don't forget to rate users who helped you!
-
March 14th, 2006, 04:37 AM
#4
Re: Back up of modified files
 Originally Posted by philkr
Code:
dwChangeHandles[0] = FindFirstChangeNotification (
"C:\\Test", // directory to watch
TRUE, // watch subtree
FILE_NOTIFY_CHANGE_ATTRIBUTES); // watch file attribute changes
This notifies if any attributes are changed.I just want to know the files which aremodified & create their back up as soon as they are modified.
Please Help
Last edited by erankushmehta; March 14th, 2006 at 04:41 AM.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 14th, 2006, 04:45 AM
#5
Re: Back up of modified files
ReadDirectoryChangesW() can notify you of all sorts of directory changes - for example, changed attributes, files added, files deleted, files modified, files renamed etc. However, it only works with Windows XP and 2000 as far as I'm aware.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
March 14th, 2006, 04:51 AM
#6
Re: Back up of modified files
what exactly u want ? can u explain?
If I Helped You, "Rate This Post"
Thanks
Guna
-
March 14th, 2006, 05:00 AM
#7
Re: Back up of modified files
 Originally Posted by Gunaamirthavelu
what exactly u want ? can u explain?
I want to be notified as soon as any file in a given directory is modified & then create its back up instantaneously.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 14th, 2006, 05:53 AM
#8
Re: Back up of modified files
 Originally Posted by erankushmehta
FILE_NOTIFY_CHANGE_ATTRIBUTES); // watch file attribute changes [/CODE]
This notifies if any attributes are changed.I just want to know the files which aremodified & create their back up as soon as they are modified.
Please Help
FILE_NOTIFY_CHANGE_ATTRIBUTES is not the only flag you can pass to the function. FILE_NOTIFY_CHANGE_LAST_WRITE is what you need.
If your target platforms match its requirements you should check the ReadDirectoryChangesW function as well. This is a function to be used in conjunction with FindFirstChangeNotification. With it you can pinpoint the changes occuring in a directory.
You can find a sample of its usage here: MSDN - fwatch
Another example is CodeProject - Directory Change Watcher
Har Har
-
March 14th, 2006, 07:51 AM
#9
Re: Back up of modified files
 Originally Posted by PadexArt
FILE_NOTIFY_CHANGE_ATTRIBUTES is not the only flag you can pass to the function. FILE_NOTIFY_CHANGE_LAST_WRITE is what you need.
Thanks, i get the notification.Now how to get the filename which was modified so that its back up may be created..
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 14th, 2006, 07:57 AM
#10
Re: Back up of modified files
 Originally Posted by erankushmehta
Thanks, i get the notification.Now how to get the filename which was modified so that its back up may be created..
This information has been provided already. Read the posts to their full extent and follow the links.
Har Har
-
March 16th, 2006, 04:46 AM
#11
Re: Back up of modified files
ReadDirectoryChanges & FILE_NOTIFY_INFORMATION will do. But i am not able to comprehend the complex parameters & getting the relevant info from the file notify structure.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 16th, 2006, 05:12 AM
#12
Re: Back up of modified files
Follow PadexArt's link to the directory change watcher. Everything is wrapped up with ready-made handlers for OnFileAdded(0, OnFileRemoved(), OnFileModified(), and OnFileNameChanged(). They don't come much easier than that.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
March 17th, 2006, 02:16 AM
#13
Re: Back up of modified files
Code:
if(!ReadDirectoryChangesW( pdi->m_hDir,
pdi->m_Buffer,//<--FILE_NOTIFY_INFORMATION records are put into this buffer
READ_DIR_CHANGE_BUFFER_SIZE,
pdi->m_bWatchSubDir,
pdi->m_dwChangeFilter,
&pdi->m_dwBufLength,//this var not set when using asynchronous mechanisms...
&pdi->m_Overlapped,
NULL))
i am getting following error:
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
I am using Windows 2000 Professional.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
-
March 17th, 2006, 03:04 AM
#14
Re: Back up of modified files
Try putting the following line in one of your header files (preferably stdafx.h )
Code:
#define _WIN32_WINNT 0x400
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
March 22nd, 2006, 03:53 AM
#15
Re: Back up of modified files
 Originally Posted by John E
Try putting the following line in one of your header files (preferably stdafx.h )
Code:
#define _WIN32_WINNT 0x400
tried..but to no avail...
Plz help.
Regards,
Ankush Mehta
"The Child is the father of the Man."
William Wordsworth
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|