0

If a folder is moved or renamed in windows system ,then how can we detect the changes made to folder using c# . If archive bit on the folder is enabled, can we check it using c# and then after saving changes in database , how can i set ready for archiving flag to false once i saved the changes?

Avy
  • 187
  • 1
  • 10
  • Are you aware about [`FileSystemWatcher`](https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx) ? What is exactly not working? – Sinatr Apr 20 '18 at 08:20
  • Yes, but this question is regarding folders. – Avy Apr 20 '18 at 08:22
  • @Avy, *Listens to the file system change notifications and raises events when a **directory**, or file in a directory, changes* – Sinatr Apr 20 '18 at 08:22
  • Using achieve bit is an [old](https://en.wikipedia.org/wiki/Archive_bit) technique, it's not reliable, since anyone can change the bit. – Sinatr Apr 20 '18 at 08:24
  • Filesystemwatcher does not detect changes made to folders when the application is not running . – Avy Apr 20 '18 at 08:26
  • Why would you want to unset the archive flag? – BugFinder Apr 20 '18 at 08:28
  • @Any, nothing will monitor changes unless it's running and monitoring. What do you want to achieve? What are those folders and what is in database? – Sinatr Apr 20 '18 at 08:30
  • There are mutliple folders in a main fixed folder on windows system. I need to save the info of that folder and inform the server. If the application is not running and changes are made to folder when app is offline, i have to inform the db and server about all the changes once the app is executed again. – Avy Apr 20 '18 at 08:46
  • Also the same changes are to be made on different system running the same app – Avy Apr 20 '18 at 08:48
  • Sounds easy. If you don't need to monitor constantly, then simply [traverse folders](https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-enumerate-directories-and-files) on startup, check their [attributes](https://msdn.microsoft.com/en-us/library/system.io.file.getattributes(v=vs.110).aspx), upload info and [set](https://msdn.microsoft.com/en-us/library/system.io.file.setattributes(v=vs.110).aspx)/[reset](https://stackoverflow.com/q/7399611/1997232) attribute. I'd not use achieve attribute, rather ask server what was already done (local database to store such info will also do). – Sinatr Apr 20 '18 at 09:03
  • Thanks sinatr. The attribute does not show up in directory suggestions . – Avy Apr 20 '18 at 09:19
  • Even the set/reset attribute is not there in directory suggetions. I am using c#. – Avy Apr 20 '18 at 09:20

0 Answers0