I have a list of files starting with a 4 digit code as below,
1) MI01_xxxx_xxxxx.pdf
2) MI01_xxx.pdf
3) MI01_xxxxx.pdf
4) MI03_xxxxx_xxxxx_xxxx.pdf
5) MI04_xxxxxxx_xxxx.pdf
6) MI04_xxx_xxx_xxxxxxxxxxx.pdf
.......
.......
Is it possible for me to check if the file exist in the directory by checking on the first 4 character of the filename? Based on the list above, if i click on code MIO1, it will list out all files starting with MIO1 (result: 3 files).
If i click on code MI02, it will give message "No files found!".
Expand|Select|Wrap|Line Numbers
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FileExists("C:\Inetpub\wwwroot\fin\attach\MI_"&Rs("FinCode")&".pdf") Then
- Response.Write("The file exist.")
- Else
- Response.Write("The file does not exist.")
- End If