471,092 Members | 1,025 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

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_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
  1. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2. If objFSO.FileExists("C:\Inetpub\wwwroot\fin\attach\MI_"&Rs("FinCode")&".pdf") Then
  3.              Response.Write("The file exist.")
  4. Else
  5.     Response.Write("The file does not exist.")
  6. End If
Above code is ok if i have the full path. Any idea? Thanks in advance :)
May 6 '10 #1
1 2149
can u bit more clear abt the issue . . I doesn't understand what the actual problem is . .

May 12 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by andylcx | last post: by
3 posts views Thread by Dave | last post: by
52 posts views Thread by paytam | last post: by
2 posts views Thread by tino | last post: by
14 posts views Thread by John Salerno | last post: by
1 post views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
6 posts views Thread by Franck | last post: by
8 posts views Thread by Anthony Papillion | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.