is there a way to identify temp directories by attributes?

  • Thread starter Thread starter Heath
  • Start date Start date
H

Heath

I'm dealing with a C# application that monitors changes to the file
system, and need to exclude irrelevent directories, temp directories
for example.

Is there any way to identify such directories, perhaps through
DirectoryInfo or something similar that might give some attribute that
temp, system, hidden, etc directories might be tagged with?

I wanted to write this code to check and ignore such directories
dynamically based on attriebutes, rather than find all the locations
that windows seems to put temp file and hard code exclusions.

Any help would be much appreciated.
 
Tem directories could be any directories within the file system and don't
have any special attribute. You can simulate what the Win32 function
GetTempPath does as follows:



string GetTempPath()

{

string res = Environment.GetEnvironmentVariable("TMP");

if ( res == null )

{

res = Environment.GetEnvironmentVariable("TEMP");

if ( res == null)

{

res = Environment. CurrentDirectory;

}

}

return res;

}

You can find also many other directories that you may want to ignore (like
cookies, temporary internet, application data, etc. ) using
Environment.GetFolderPath You must take into account that all those methods
return the desired directories for the current logged on user.



Hope this help,

Idael
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top