Note that there are some explanatory texts on larger screens.

plurals
  1. POAlternatives ways to getting the properties of the file?
    primarykey
    data
    text
    <p>Background:</p> <p>I have a file monitoring service that watches for changes in the files on the local system using the <code>FileSystemWatcher</code> class and i am handling for events like <code>Created</code>,<code>Deleted</code>,<code>Renamed</code>. When these events are triggered,I would simply want to GET THE PROPERTIES OF THE FILE such as <code>FileName</code>,<code>FileSize</code>,<code>CreationTime</code>,<code>LastAccessTime</code>,<code>LastWriteTime</code> using the <code>FileSystemInfo</code> class.</p> <p>Problem:</p> <p>While this service is running, I am unable to uninstall some programs for example (Microsoft Security Essentials). I have a feeling that these service is HANGING ON TO THE RESOURCES of the files marked for deletion because I can only uninstall those programs if only this service is running. </p> <p>My Question is how can I <code>GET THE PROPERTIES OF THE FILE</code> (as specified above) in an <code>ALTERNATIVE</code> &amp; efficient way <code>without hanging on to the resources of the file</code> ?</p> <p>Here is my code using the <code>FileSystemInfo</code></p> <pre><code>public void OnCreate/OnRenamed(object source, FileSystemEventArgs e) { FileInfo file = new FileInfo(e.FullPath); String output = "&lt;Event&gt;&lt;TimeStamp&gt;" + currentTime + "&lt;/TimeStamp&gt;"; output += "&lt;Name&gt;" + action + "&lt;/Name&gt;"; output += "&lt;Properties&gt;&lt;FileName&gt;" + file.Name + "&lt;/FileName&gt;"; output += "&lt;FullPath&gt;" + file.FullName + "&lt;/FullPath&gt;"; output += "&lt;FileSize&gt;" + file.Length + "&lt;/FileSize&gt;"; output += "&lt;CreationTime&gt;" + String.Format("{0:yyyyMMdd-HHmmss.fff}", file.CreationTime) + "&lt;/CreationTime&gt;"; output += "&lt;LastAccess&gt;" + String.Format("{0:yyyyMMdd-HHmmss.fff}", file.LastAccessTime) + "&lt;/LastAccess&gt;"; output += "&lt;LastWriteTime&gt;" + String.Format("{0:yyyyMMdd-HHmmss.fff}", file.LastWriteTime = DateTime.Now) + "&lt;/LastWriteTime&gt;&lt;/Properties&gt;&lt;/Event&gt;"; } </code></pre> <p>Sincerely, Derek</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload