Mik Mak
asked on
FileExists in VS 2005 VB always returns false
I'm having issues with a simple FileExist check in old VS 2005 VB project that I need to make som alterations to.
The check for a file always returs false - not matter if I use
Dir("c:\")
or
My.Computer.FileSystem.Fil eExists("c :\")
Any help would be much appreciated
The check for a file always returs false - not matter if I use
Dir("c:\")
or
My.Computer.FileSystem.Fil
Any help would be much appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use this way... And i'm assuming you want to check for abc.xlsx file
Saurabh...
dim filename as string,xpath as string
xpath="C:\"
Filename="abc.xlsx"
If Len(Dir(xpath & filename)) = 0 Then
MsgBox "File does not exist"
else
'your code here
end if
Saurabh...
ASKER
Hmm, now it also Work with backslash - I'm confused :)
Bojerene,
In order it to work you need to define the file name in it which was missing once you define the file name and check for len that way you can trap whether file is their or not...
Saurabh...
In order it to work you need to define the file name in it which was missing once you define the file name and check for len that way you can trap whether file is their or not...
Saurabh...
ASKER