Monitoring the closing of a specific c # file

I am developing a windows app to complement our web app, this is a small document management system like dropbox, I have to sync files automatically when it is closed for example. if a .dwg file (AUTOCAD) is opened in my application, the event should fire when that particular file is closed, is this possible with a class Filesystemwatcher

? The problem is that in AUTOCAD the file opens as tabs, I know we can do this in MS Office applications with interop library. How can we do the same for applications like AUTOCAD and Photoshop?

+3


source to share


3 answers


Try using the FileSystemWatcher Changed event. Something like that:



    FileSystemWatcher watcher = new FileSystemWatcher();
    watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
       | NotifyFilters.FileName;
    // Only watch AutoCAD files.
    watcher.Filter = "*.dwg";
    watcher.Changed += new FileSystemEventHandler(OnChanged);

      

+3


source


Within AutoCAD, you can also develop a plugin (just like for MS Office) using your .NET API.

There is a DocumentCollection.DocumentDestroyed event that fires when the document is closed (save 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 Database.SaveComplete event

Either way, this requires an application that works with AutoCAD, if you are tracking files (FileSystemWatcher) it should be easier.

0


source


For AutoCAD, use FileSystemWatcher

to view the created and deleted .wwl file. This file contains metadata about who opened the file and when. It is removed when the file is closed and the lock is released. Later versions also have a .dwl2 file. All you need to look at is it might stay if AutoCAD crashes.

I don't remember if it is created when the file is opened read-only, but there is no need to sync it anyway.

0


source







All Articles