G
Guest
Hello,
I am writing an application that needs to read a file that is already open by another process for writing.
When I do the following:
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
I get the following exception:
{"The process cannot access the file \"EV1_0.log\" because it is being used by another process." }
I wrote a test program in "regular" C as follows and do not get this error. It can always read this file.
if ((fp = fopen("EV1_0.log", "r")) == NULL)
{
printf("Failed to open file");
return;
}
if (fgets (result,200, fp) == NULL)
{
printf("Could not read from file");
return;
}
printf(result);
The process that has the file open for writing is written in C and cannot be modified.
Does anyone know how I can access this file for reading using C#? I tried using FileShare.Read as one of the FileStream constructor values and that does not seem to help.
Thanks,
Trellow
I am writing an application that needs to read a file that is already open by another process for writing.
When I do the following:
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
I get the following exception:
{"The process cannot access the file \"EV1_0.log\" because it is being used by another process." }
I wrote a test program in "regular" C as follows and do not get this error. It can always read this file.
if ((fp = fopen("EV1_0.log", "r")) == NULL)
{
printf("Failed to open file");
return;
}
if (fgets (result,200, fp) == NULL)
{
printf("Could not read from file");
return;
}
printf(result);
The process that has the file open for writing is written in C and cannot be modified.
Does anyone know how I can access this file for reading using C#? I tried using FileShare.Read as one of the FileStream constructor values and that does not seem to help.
Thanks,
Trellow