dcsimg
May 26, 2018
Hot Topics:

Intermediate Page Two

  • November 19, 2002
  • 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



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

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

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date