Link to home
Start Free TrialLog in
Avatar of dimensionav
dimensionavFlag for Mexico

asked on

How to know if a file exists and how to create it?

How can I know if a file exists and If it doesn´t, how could I create an empty txt file?

Regards
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

If Dir("C:\Test.txt") <> "" Then
  Msgbox "File exists"
Else
  Msgbox "File does not exist"
End If 

Open in new window

@echo off
c:
if not exist C:\test.txt echo. > c:\test.txt
To create a blank file just issue an Open statement for the file you want.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial