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.
Printable View
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.
Call CopyFile to copy the original file in a new one before saving the modifications.
This function will help to be notified of modification: FindFirstChangeNotification()
Quote:
Originally Posted by philkr
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.Code:dwChangeHandles[0] = FindFirstChangeNotification (
"C:\\Test", // directory to watch
TRUE, // watch subtree
FILE_NOTIFY_CHANGE_ATTRIBUTES); // watch file attribute changes
Please Help
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.
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.Quote:
Originally Posted by Gunaamirthavelu
FILE_NOTIFY_CHANGE_ATTRIBUTES is not the only flag you can pass to the function. FILE_NOTIFY_CHANGE_LAST_WRITE is what you need.Quote:
Originally Posted by erankushmehta
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
Thanks, i get the notification.Now how to get the filename which was modified so that its back up may be created..Quote:
Originally Posted by PadexArt
This information has been provided already. Read the posts to their full extent and follow the links.Quote:
Originally Posted by erankushmehta
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.
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.
i am getting following error: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 using Windows 2000 Professional.Quote:
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
Try putting the following line in one of your header files (preferably stdafx.h )
Code:#define _WIN32_WINNT 0x400
tried..but to no avail...Quote:
Originally Posted by John E
Plz help.