Reading File inuse by other process.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am trying to read a file or get it's size while this file is written by
another process.
When i use the windows explorer i can read the file or check it's size .
When i use the FileInfo(size) it hangs until file is released.
Is there another way?

Thanks
 
Hi
I am trying to read a file or get it's size while this file is written by
another process.
When i use the windows explorer i can read the file or check it's size .
When i use the FileInfo(size) it hangs until file is released.
Is there another way?

Thanks

When you attempt to open the file, make sure you are specifying the
appropriate sharing mode. Can you show some code that illustrates
your problem?

Chris
 
Thanks for quick respons here is the relevant code

int lastvalue =0;
string fPath = @"c:\temp\build.log";
FileInfo FI = new FileInfo(fPath);
while (1>0)
{
if (lastvalue - FI.Length == 0)
{
iCounter++;
lastvalue = FI.Length;
if (iCounter > 20)
{
MessageBox.Show("times up");
break;
}

}
else
{
iCounter = 0;
}
lastvalue = FI.Length;
Thread.Sleep(SleepTime);
}
 
Back
Top