dcsimg
November 28, 2020
Hot Topics:

Intermediate Page Two

  • By Karl Moore
  • Send Email »
  • More Articles »

File Sizes

To find out the size of a file, in bytes, use the FileLen() function. Here's an example:

MsgBox FileLen("c:\autoexec.bat")

That's it!

-- Mysterious AppMan's younger brother, Colin.

File Operations

Did you know Visual Basic provides complete support for all basic file operations? Here's my top three file handling code snippets:

Copy a File:

FileCopy("c:\oldfile.txt", "c:\newfile.txt")

Delete a File

Kill("c:\oldfile.txt")

Move a File

Name "c:\oldfile.txt" as "c:\newfile.txt"

Hah, who needs the API?

-- Danny Weidman, Cardiff.

Get a File Date and Time

You can use the FileDateTime() function to retrieve details of when a file was last modified.

-- David Homer, Canada.

Check if a File Exists

Here's a groovy little function I wrote to check whether a file actually exists:

Public Function FileExists(FileName As String) As Boolean    If Dir(FileName) = "" Then        FileExists = False    Else        FileExists = True    End IfEnd Function

You use it like this:

If FileExists("c:\nofilehere.txt") = False Then _MsgBox ("File does not exist!")

-- Barry Manilow, Copacobana (North of Havana).





Page 3 of 4



This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date