How to check file exist if the file starting with certain code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Adya
    New Member
    • May 2010
    • 1

    How to check file exist if the file starting with certain code?

    Hi all,

    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_xxxx x_xxxx.pdf
    5) MI04_xxxxxxx_xx xx.pdf
    6) MI04_xxx_xxx_xx xxxxxxxxx.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!".

    Code:
    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
    Above code is ok if i have the full path. Any idea? Thanks in advance :)
  • nedu
    New Member
    • Nov 2006
    • 65

    #2
    Originally posted by Adya
    Hi all,

    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_xxxx x_xxxx.pdf
    5) MI04_xxxxxxx_xx xx.pdf
    6) MI04_xxx_xxx_xx xxxxxxxxx.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!".

    Code:
    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
    Above code is ok if i have the full path. Any idea? Thanks in advance :)
    can u bit more clear abt the issue . . I doesn't understand what the actual problem is . .

    Regards
    Nedu

    Comment

    Working...