Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileExists() method not found 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
In any program, one needs to check if a such-n-such file is present in a such-n-such directory.
The known way of checking up a file's presence is FileExists() function/method.
I tried to use it as

Code:
FileSystem.FileExists(lcSrcDir & pcFilNamXML)

... in the frmMain.cmdRun.Click() event and, once I've it printed this above code in the code editor window, it gave me "grief" with the following error message:
"'FileSystem' is ambiguous, imported from the namespaces or types 'Microsoft.VisualBasic.FileIO, Microsoft.VisualBasic".
I do have both

Code:
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.FileIO

in the VB module, so... I'm confused!
What am I doing wrong there?
TIA!


Regards,

Ilya
 
Sample code from here

Code:
Dim FileName = "One.docx"
Dim FilePath = "C:\TEMP" & "\" & FileName

If System.IO.File.Exists(FilePath) Then
    MsgBox("The file exists")
Else
    MsgBox("the file doesn't exist")
End If


---- Andy

There is a great need for a sarcasm font.
 
Your Imports are ambiguous - as the error message is trying to tell you; you do not need both

[tt]Imports Microsoft.VisualBasic[/tt]

and

[tt]Imports Microsoft.VisualBasic.FileIO[/tt]

Just use the latter, and then [tt]FileSystem.FileExists[/tt] works just fine



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top