I've got some ASP.net pages that write files for use as attachments
(actually I have other pages that either create or destroy temporary files
where this is just as pertinent). I generally have no problem either
creating the file or reading from and existing file, but when I go to do the
next step either writing to the newly created file or destroying the deleted
file I often encounter an exception something along the line of:
The process cannot access the file "c:\foo.txt " because it is being used by
another process.
Is there anyway I can test for this condition and wait for a period of time?
I have these statements in try/catch blocks, that are nested within a while
blocks, the while block has conditions for success and number of trys, so
the while block can exit with an unsuccessful attempt if it takes more than
10 tries or whatever I set it for.
Is there a better way?
(actually I have other pages that either create or destroy temporary files
where this is just as pertinent). I generally have no problem either
creating the file or reading from and existing file, but when I go to do the
next step either writing to the newly created file or destroying the deleted
file I often encounter an exception something along the line of:
The process cannot access the file "c:\foo.txt " because it is being used by
another process.
Is there anyway I can test for this condition and wait for a period of time?
I have these statements in try/catch blocks, that are nested within a while
blocks, the while block has conditions for success and number of trys, so
the while block can exit with an unsuccessful attempt if it takes more than
10 tries or whatever I set it for.
Is there a better way?