Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File.Exists(string path) misbehavior
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
OS:
Windows 2000
Divers
Thread ID:
01009851
Message ID:
01009861
Vues:
21
David,
I tried running the code you posted and I do not see the behavior that you describe. I am not running this over a Novell network. Have you tried stepping through the code in the debugger to make sure there isn't something silly going on (like a missing slash in the path or a filename without ext).
I must agree with you that I find it hard to belive that M$ has a bug like this in their File class. Hopefully someone else will be able to test your code against a Novell server.

Einar
>I am having a problem using File.Exists.
>
>I want to copy files from a remote server to a local directory on a Novell Network between two windows machines. I create a string array containing filenames from a database query.
>
>I am using File.Exists to first ensure the file exists and then copy it locally. After the first time File.Exists returns false, it returns false thereafter for the existing files that I check, even though I can see they exist using Windows Explorer.
>
>I have done the obvious things, like trying to check different numbers of existing files before checking my first non-existent one, and making sure that the paths are correct. If I restart my program, the problem goes away until File.Exists returns false for the first time again.
>
foreach (string filename in fileNameArray)
>{
>    remoteFilename = RemoteDirectory + filename;
>    localFilename =  LocalDirectory + filename;
>    if(File.Exists(remoteFilename))
>    {
>        // Copy file to local directory
>        File.Copy(remoteFilename, localFilename, false);
>    }
>}
>I was originally just making the copy attempt in a try-catch block without checking for the file's existence, but the problem kept occuring: after trying to copy one non-existent file and getting a FileNotFoundException, it threw FileNotFoundExceptions for all following files I tried to copy, even though they existed.
>
>It's hard to believe it's a bug in the .NET File object. I tried using the FileInfo object, since it isn't static, hoping that by recreating a FileInfo object every time I checked for file existence, whatever was "stuck" false would be unstuck. It didn't work.
>
>If account permissions are lacking, File.Exists returns false even if the file is there. The only non-bug problem that I can think of is that our network security policy is trying to prevent file snooping by removing privileges from an account that looks for non-existent files. We use Novell networking, but I don't know the version. I can ask our network admin about this possibility on Monday.
>
>Does anyone have any other idea about what the problem might be? The fact that it goes away after I restart the program leads me to believe that the static File object is destroyed and the problem is fixed and perhaps FileInfo is just a non-static wrapper around File.
>
>Thanks for any ideas that anyone has.
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform