Hi
I'm trying to detect the hidden (although I've seen it for a split second in Windows File Explorer) .tmp file that's created in the FileSystemWatcher Create Event. The .tmp file appears in the same directory as the file that's created. I'm using the example for FileSystemWatcher here:
https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx
In the Create event I find the hidden .tmp file that is automatically generated changes my e.changeType to "Deleted" when it is deleted after a split second. So I'm trying to detect it and stop it from affecting the rest of the code block. I tried this code sample I found on the web.
But the first line gives me an error as the hidden .tmp file isn't part of e.FullPath. How can I change this to detect the hidden .tmp file?
Thanks.
I'm trying to detect the hidden (although I've seen it for a split second in Windows File Explorer) .tmp file that's created in the FileSystemWatcher Create Event. The .tmp file appears in the same directory as the file that's created. I'm using the example for FileSystemWatcher here:
https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx
In the Create event I find the hidden .tmp file that is automatically generated changes my e.changeType to "Deleted" when it is deleted after a split second. So I'm trying to detect it and stop it from affecting the rest of the code block. I tried this code sample I found on the web.
FileAttributes attr = System.IO.File.GetAttributes(e.FullPath); FileInfo fi = new FileInfo(e.FullPath); if ((attr & FileAttributes.Hidden) == FileAttributes.Hidden || fi.Extension == ".tmp") { MessageBox.Show(".tmp file found"); }
But the first line gives me an error as the hidden .tmp file isn't part of e.FullPath. How can I change this to detect the hidden .tmp file?
Thanks.
Last edited: