A fancy case of a file that exists and does not exist

In .Net 3.5, I have the following code.

If File.Exists(sFilePath & IndexFileName & ".NX") Then
  Kill(sFilePath & IndexFileName & ".NX")
End If

At runtime on the same client computer, I get the following exception, over and over again when this code executes

Source: Microsoft.VisualBasic
TargetSite: Microsoft.VisualBasic.FileSystem.Kill
Message: No files found matching 'I:\RPG\HGIAPVXD.NX'.
StackTrace: 
   at Microsoft.VisualBasic.FileSystem.Kill(String PathName)
(More trace that identifies the exact line of code.)

There are two people on different computers working with this code, but only one of them gets an exception. An exception does not occur every time, but it happens regularly. (Several times per hour.) The code is not in a loop and does not run continuously, more than just every few minutes or so.

At first glance, this looks like a race condition, but given how rarely this code runs and how often an error occurs, I think there should be something else.

, , . , , .

+3
3

, , , " ?" , - ( , --- )?

, Microsoft.VisualBasic.FileSystem.Kill "" "". .

+5

, Kill , , System.IO.File.Delete()

    Try
        System.IO.File.Delete(sFilePath & IndexFileName & ".NX")
    Catch ex As System.Exception
        ...
    End Try

File.Exits , File.Delete() .

0

Is there a chance that I: drive is a network drive? it could be a network problem ... or maybe a race condition

0
source

Source: https://habr.com/ru/post/1763834/


All Articles