Reading File inuse by other process.

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
 
C

Chris Dunaway

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
 
G

Guest

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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top