简体   繁体   中英

How to get file name and compare in vb.net?

I am using the below code to get file name using FILE created event.

WriteSilentLog("File Created: " & e.FullPath & " " & Now().ToString)
Dim sFileName As String
Dim FileExt As String

TestPath = e.FullPath '"\\server\E\Accpac Imports\production\reports\1234_maoingfhgh_90676904.pdf"
sFileName = Path.GetFileName(TestPath)
Filename.Text = sFileName

It works fine. At the moment the all the file names are end with 'XXXXXXXX' eight digit. I am about to get another file name end with 'XXXXXXXX' random digit of 8 .

My question is How do I differentiate the filename like below

' Pseudocode
IF filename Like last 8 digits that have changed in every file Then
    open that pdf file that contain 8 random digits in last
Else If    
    Do somthing
End IF

Please Help

If you want to find a file with a known 8 digits at the end;

Dim known as integer = 12345678
Dim files = Directory.GetFiles("c:\temp\", "*_" & known & " .pdf", SearchOption.TopDirectoryOnly)

'Do something with the files array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM