Mar 16, 2004 #1 desprits Programmer Feb 14, 2004 40 CA I would like to know what should I do to know if a files exist in VB. Exemple : if File1 exist then else Create File1 endif
I would like to know what should I do to know if a files exist in VB. Exemple : if File1 exist then else Create File1 endif
Mar 16, 2004 #2 BiggerBrother Technical User Sep 9, 2003 702 GB create a reference to microsoft scripting runtime, under references in the project menu. Then use the following code: Dim FSO As FileSystemObject Set FSO = New FileSystemObject If FSO.FileExists("C:\Folder\worddoc.doc") = True Then 'file exists else 'file not present. End if BB Upvote 0 Downvote
create a reference to microsoft scripting runtime, under references in the project menu. Then use the following code: Dim FSO As FileSystemObject Set FSO = New FileSystemObject If FSO.FileExists("C:\Folder\worddoc.doc") = True Then 'file exists else 'file not present. End if BB
Mar 16, 2004 Thread starter #3 desprits Programmer Feb 14, 2004 40 CA Thank you very much ! Upvote 0 Downvote
Mar 16, 2004 Thread starter #4 desprits Programmer Feb 14, 2004 40 CA What the refecence of that ? FileSystemsObject Upvote 0 Downvote
Mar 16, 2004 #5 strongm MIS May 24, 2001 20,149 GB As BiggerBrother said the normal reference required to get access to the FileSystemObject is the Microsoft Scripting Runtime Upvote 0 Downvote
As BiggerBrother said the normal reference required to get access to the FileSystemObject is the Microsoft Scripting Runtime
Mar 16, 2004 #6 AndyTWI Programmer Feb 26, 2004 17 US Far easier IMO is the Dir$() function: Code: If LenB(Dir$("C:\yourfile.txt")) = 0 Then ' file does not exist, create it Else ' file exists End If The Dir$() function will return a nullstring if the file does not exist. Upvote 0 Downvote
Far easier IMO is the Dir$() function: Code: If LenB(Dir$("C:\yourfile.txt")) = 0 Then ' file does not exist, create it Else ' file exists End If The Dir$() function will return a nullstring if the file does not exist.