someone might have the file open for reading.....so you cannot exclusively touch it.
So check if file exists and can be opened exclusive
<pre lang="C++">public static FileExist DoesFileExistOnServer(String FolderAndFileName)
{
FileExist doesExist = FileExist.No;
if (!String.IsNullOrEmpty(FolderAndFileName))
{
FileInfo fi = new FileInfo(FolderAndFileName);
if (fi.Exists)
{
FileStream stream = null;
try
{
using (stream = File.Open(FolderAndFileName, FileMode.Open, FileAccess.Write, FileShare.None))
{
if (stream.CanWrite)
doesExist = FileExist.Yes;
else
doesExist = FileExist.Transferring;
}
}
catch (Exception err)
{
doesExist = FileExist.Transferring;
}
}
}
return doesExist;
}