Last post Jun 17, 2019 03:36 AM by Yongqing Yu
Jun 15, 2019 10:29 AM|alihusain_77|LINK
I have a file "2_2018-0002-200A_enc.docx" which is located on the path "D:\E\MusrasalatStorage\Undersecretary"
What I tried to make to delete the above file is as following:
Public Sub RemoveAttachments(ByVal StorageUnit As Integer, ByVal LetterID As String, ByVal No As Integer)
Dim CharString = "ABCDEF"
Dim i As Integer = 0
Dim StoredFileLetterID As String
Dim ServerPathPF As String = TDClass.GetTheServerStoragePath(StorageUnit)
For i = 0 To 5
StoredFileLetterID = No & "_" & LetterID
TheAttachedFileServerPath = ServerPathPF & StoredFileLetterID & CharString(i) & "_" & "enc" & "." & "*"
If System.IO.File.Exists(TheAttachedFileServerPath) = True Then
i = i + 1
All the variables are accurate. I mean,
ServerPathPF = "D:\E\MusrasalatStorage\Undersecretary".
StoredFileLetterID = "2018-0002-200"
CharString(I) = "A"
So why it is returning False value? I want to remove the file
Jun 15, 2019 11:00 AM|PatriceSc|LINK
Look directly at TheAttachedFileServerPath. It ends with an * character and so it can't match an existing file (it should be an actual file name, not a pattern). When in doubt I'm trying to actually read or write the file to see what happens which usually
reveals clearly the problem (afaik FileExists return true if the file is found and false otherwise even for example if folders are missing etc...).
Jun 17, 2019 03:36 AM|Yongqing Yu|LINK
According to your description, I recommend that you use breakpoints to detect the value of the
TheAttachedFileServerPath variable while the code is running.
By getting the content of the variable, you could use the path to query the file locally to see if there are corresponding files.
You could also refer to the following links: