V
Vai2000
Hi All, I had posted a File IO Race condition question sometime back. With
all your advice now I am opening a file to check whether a valid File Handle
is returned or not? If not then I sleep for sometime and retry it.
Problem is when I re open the File I am missing a line? Any Clues?
bool IsFileInUse(string inputFileUNC)
{
bool bRet=true;
FileStream fs=null;
try
{
fs=new FileStream(inputFileUNC, FileMode.Open, FileAccess.Read,
FileShare.None);
bRet=false;
}
catch
{
// exception....
}
finally
{
if(fs!=null)
fs.Close();
}
return bRet;
}
Next time when the file handle is good I read the file like this
FileStream freader = new FileStream(this.fileName, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
StreamReader reader = new StreamReader (freader);
Can someone help with the problem?
TIA
all your advice now I am opening a file to check whether a valid File Handle
is returned or not? If not then I sleep for sometime and retry it.
Problem is when I re open the File I am missing a line? Any Clues?
bool IsFileInUse(string inputFileUNC)
{
bool bRet=true;
FileStream fs=null;
try
{
fs=new FileStream(inputFileUNC, FileMode.Open, FileAccess.Read,
FileShare.None);
bRet=false;
}
catch
{
// exception....
}
finally
{
if(fs!=null)
fs.Close();
}
return bRet;
}
Next time when the file handle is good I read the file like this
FileStream freader = new FileStream(this.fileName, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
StreamReader reader = new StreamReader (freader);
Can someone help with the problem?
TIA