I am developing a windows application to compliment our web application, it is a small document management system like dropbox, I have to automatically sync the files on its closure, for e.g. if a .dwg (AUTOCAD) file is opened through my application, an event should trigger on that particular file’s closure, is it possible with Filesystemwatcher
class? The problem is that in AUTOCAD the file is opened as tabs, I know we can do this in MS Office applications with interop library. How we can do the same for applications like AUTOCAD and Photoshop?
3
Answers
Try using FileSystemWatcher’s Changed event. Something like that:
Inside AutoCAD you can also develop plugin (just like for MS Office) using its .NET API.
There is a DocumentCollection.DocumentDestroyed event that is triggered when you close a document (saving or not): http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer‘s%20Guide/index.html?url=WS1a9193826455f5ff2566ffd511ff6f8c7ca-4875.htm
Or you can use the Database.SaveComplete event
Anyway, this will need an app running with AutoCAD, if you track the files (FileSystemWatcher) should be easier.
For AutoCAD use
FileSystemWatcher
to watch for the .dwl file being created and deleted. That file has the metadata regarding who opened the file and when. It is deleted when the file is closed and the lock is released. Later versions have a .dwl2 file as well. Things to watch – it can get left behind if AutoCAD crashes.I don’t recall if it is created when a file is opened read-only but there is no need to sync it in that case anyway.