Deleted file still appears in Directory.GetFiles result
I have two webmethods. The first is:
void deleteFile(string filePath)
{
File.Delete(filePath);
}
The other is:
string[] getAllFile()
{
// at the same folder....
Directory.GetFiles("*.xml");
.....
return ....
}
I'm calling these methods like so:
deleteFile("1.xml")
getAllFile();
Despite dele开发者_JAVA百科ting the "1.xml" file, the call to Directory.GetFiles("*.xml");
still returns "1.xml" in the results. In other words, it doesn't seem to have been deleted.
And then, when I loop the result , try to read the file , get the FileNoFoundException
I've found that the DirectoryInfo/FileInfo classes do not always update. In those instances you need to call the Refresh method on the Directory/File instances.
I don't know, but I suspect that result of your webmethods are being cached somewhere.
精彩评论