Intermediate Page Two, Page 3
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).
0 Comments (click to add your comment)
Networking Solutions
