Delete .txt file if file size = 0

J

John

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
 
M

Marshall Barton

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
 
R

Rob Oldfield

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top