Mar 16, 2004 #1 desprits Programmer Joined Feb 14, 2004 Messages 40 Location 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 Joined Sep 9, 2003 Messages 702 Location 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 Joined Feb 14, 2004 Messages 40 Location CA Thank you very much ! Upvote 0 Downvote
Mar 16, 2004 Thread starter #4 desprits Programmer Joined Feb 14, 2004 Messages 40 Location CA What the refecence of that ? FileSystemsObject Upvote 0 Downvote
Mar 16, 2004 #5 strongm MIS Joined May 24, 2001 Messages 20,263 Location 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 Joined Feb 26, 2004 Messages 17 Location 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.