Directory.GetFiles and file access?
Posted on 2011-04-21
I'm doing a Directory.GetFiles(strPath, strType) to get a list of files in a directory.
Then I am going through each file to process it. I'm doing that with a
foreach (string file in Files)
*NOTE: I'm assigning the files to an array from teh Directory.GetFiles statements.
Now, the problem is IF a file that I'm working with is being access by somebody or something else then the "do something" will fail.
I want to skip that file then all together.
Was I was thinking about doing was before I "do something" I wanted to see about renaming the file to a file with the same name. So something like File.Move(file, file);
Would/should that work or is there another way?
Any information would be greatly appreciated.