Delete .txt file if file size = 0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In access,I create a .txt file in a certain folder. Is there a way in code
to look at that folder and if the .txt file is a 0 length text file to delete
it.

Thanks,
John
 
John said:
In access,I create a .txt file in a certain folder. Is there a way in code
to look at that folder and if the .txt file is a 0 length text file to delete
it.

Use the FileLen function
 
Function FSize()
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("c:\xx.txt")
FSize = f.Size
End Function

....though it'd be more efficient to check, when creating the file, if
there's any data. If there isn't, don't create the file.
 
Back
Top