I did a little more research, and I believe I found what you need.
IF YOUR application is the one that's writing to the file, you should use
share access. That is, when you open the file to write to it, you can
specify several different file modes, and one of them is sharing. Use
System.IO.FileShare.Read to be enable it to share with other processes that
wish to read from the file while it's being updated.
on the other hand, if you don't have the ability to change the code of the
program that's writing to the file, then you will just have to continue to
try to open it until that process is done with the file. If the process
that's writing the file never releases control of the file, then it's not
possible (as far as I know).
Chris LaJoie
"Tom" <da*****@fhlbcin.com> wrote in message
news:04****************************@phx.gbl...
Chris:
Thanks for that but I'm still having trouble.
See I wish to access a file (CrawlerStatus.txt) to see if
the search is done. CrawlerStatus.txt is a text file that
gets updated by a third party software.
Anyway, when I used StreamReader object, to get the
contents WHILE the process was updating the file, I got an
error.
So I thought copying it and then use StreamReader to query
the copied file contents would do the trick. But I'm
getting the same error.
So do you know of a way to access a file while its being
updated so as to not harm it?
TOm-----Original Message-----
using System.IO;
....
public static bool copyFile
(string source, string destination, bool overwrite)
{ File.Copy(source, destination, overwrite);
}
"Tom" <da*****@fhlbcin.com> wrote in message
news:03****************************@phx.gbl... I am having trouble when I read a file and another process is trying to update it.
So I need a rountine to copy a file in asp.net.
Can anyone assist?
Thanks
Tom
.