File API Routines
Updated Monday December 26, 2011
   
Category
Topic
Attributes
vb6
vb5
vb4-32
FindFirstFile: Changing File and/or Folder Attributes Recursively
Recursive file searching providing the ability to reset file or folder attributes. March 25.2001

GetFileVersionInfo: File Search and File Property Info
Recursive file searching that additionally retrieves select file property information.  Nov 29.1999



Copying
vb6
vb5
vb4-32
CopyFile: Copy Files En-mass to a New Folder
Pass a source and target folder and a filespec, and have this routine do the copying. Will create the destination folder if it doesn't exist. Sept 4.1997

CopyFileEx: Create a File Backup App
Creating a backup app that compares files before copying. Dec 20.1999

CopyFileEx: Create a File Backup App with a Progress Callback
Backup app for NT that uses the CopyProgressRoutine callback to track file copy progress. Dec 20.1999

SHFileOperation: Copy or Move an Entire Directory
Using the SHFileOperation API, you can easily move or copy entire directories, including all subdirectories.

SHFileOperation: Copy, Move or Delete Files
Build on the SHFileOperation Recycle Bin routine to include multiple file deletions, file moving and file copying, all with the same routine.



Dates
vb6
vb5
vb4-32
FindFirstFile: Determining the Oldest Folder (Recursive)
How to recursively iterate through the file system to determine the oldest folder. Sept 6.2005

SetFileTime: Modify the Date/Time of Folders and Files
How to retrieve/change the Created, Last Accessed or Last Modified date/time for files or folders under NT, 2000 and XP. Sept 21.2002

SetFileTime: Obtain and Change a File's Created, Accessed and Modified Dates
Once the debug code provided is removed, you'll be left with a half-dozen line routine to retrieve and set/reset a file's Created, Last Accessed or Last Modified dates.



Directories
vb6
vb5
vb4-32
FindFirstFile: An API 'FolderExists' Routine
Using FindFirstFile to determine if a specified folder exists. Oct 20.1999

Fastest Checks for Files or Folders
Two short routines: one to return True if a specified folder contains other subfolders, and one to detect files. Dec 30.2004

FindFirstFile: Determining the Oldest Folder (Recursive)
How to recursively iterate through the file system to determine the oldest folder. Sept 6.2005

CreateDirectory: Creating Nested Folders
Two methods to created a nested hierarchy of folders for vb4-32, vb5 and vb6.Sept 19.1998

FindFirstFile: Calculating Folder Size, Recursive
Stripping out the non-essential code from our FindFirstFile routines to return just the total bytes in the specified folder and optionally, its subfolders.
Mar 30.2002

GetSecurityDescriptorOwner: Local or Remote File or Folder Owner
GetFileSecurity, LookupAccountSid and GetSecurityDescriptorOwner return the owner of a file or a folder on a local or remote machine. Jan 17.2006

NetFileEnum: Get Open File Info from a Specified Machine
Use NetFileEnum to return a listing of open files and owners on remote machines. Apr 5.2003



Drives
vb6
vb5
vb4-32
GetLogicalDriveStrings: An API 'DriveExists' Routine
Using GetLogicalDriveStrings to determine if a specified drive exists. Oct 20.1999

Determining if a Floppy Drive is Ready
Four wrapper routines that each determine if a removable drive is ready. Sept 1 2.1999


Drive Info
vb6
vb5
vb4-32
DeviceIoControl: Determine Media Type for CD/DVD Drives
Using DeviceIoControl to identify and differentiate between DVD and CD drives.  Aug 29.2004

GetDiskFreeSpace: Free Disk Space on Windows 95 (or Small Partitions)
The code to determine clusters, sectors, used and free space on a release version of Win95 (pre-OSR/2).

GetDiskFreeSpaceEx: Free Disk Space on a Fat32 or NTFS Drive
The code to determine total, used and free space on a Fat32 drive made with Windows 95 OSR2 or Windows 98.

Determining if a Floppy Drive is Ready
Four wrapper routines that each determine if a removable drive is ready. Sept 1 2.1999

GetDriveType: Enumerate and Identify Available System Drives
API method to determine a system's installed drives and their type.

GetLogicalDriveStrings: Determine if a Specific Drive Exists
API method to determine if the system has a specific drive letter.

How to Obtain a System's CD-ROM Drive Information
Code to determine if the target system has a CD-ROM installed, obtain its drive letter, and the volume name of an inserted CD.

GetDiskFreeSpaceEx: Detailed Drive Info
Retrieve drive and volume information for any size partition or drive on any 32-bit platform. July 29 .1999

Using GetDiskFreeSpaceEx for Disk Information on 32-bit Windows
Four wrappers for retrieving disk free and used space info on any 32-bit Windows system.  Dec 23 .1999



Ellipses
vb6
vb5
vb4-32
DrawText: Add Ellipses to a File Path
Create an ellipsed string by specifying the size of the desired string in characters. May 20.2004

PathCompactPath: Adding Ellipses to a File Path
Create an ellipsed string in a length specified in pixels. May 20.2004

PathCompactPathEx: Adding Ellipses to a File Path
Create an ellipsed string to fit within a specific RECT, with path or end ellipses. May 20.2004



Exists
vb6
vb5
vb4-32
GetLogicalDriveStrings: An API 'DriveExists' Routine
Using GetLogicalDriveStrings to determine if a specified drive exists. Oct 20.1999

FindFirstFile: An API 'FileExists' Routine
For the API purists, the popular FileExists wrapper via API. June 17.1998

FindFirstFile: Fastest Tests for Files or Subfolders
Wrapper routines to determine if a specific folder contains either files or subfolders. Dec 20.2004

FindFirstFile: An API 'FolderExists' Routine
Create an ellipsed string to fit within a specific RECT, with path or end ellipses. Oct 19.1999



Extraction
vb6
vb5
vb4-32
FindFirstFile: Extract Filename from a Full Path
Small function returning the filename alone from a full path and filename. Feb 11.2001


File Associations
vb6
vb5
vb4-32
RegSetValueEx: Create a Registered File Association
Now your application will launch whenever its associated file is clicked in Explorer. June 29.1998

FindExecutable: Find Exe Associated with a Registered Extension
Use FindExecutable to retrieve the file associated with a particular file extension. Sept 1 2.1999

FindExecutable: Obtain Exe of the Default Browser
Using FindExecutable and a temporary file to determine the application associated with html files. Oct 13.1999

RegEnumKeyEx: Retrieve the Registered File Associations
Use RegEnumKeyEx and SHGetFileInfo to list all the registered file extensions on the system. March 18.2001

CreateProcess: Start Separate Instances of the Default Browser
Using FindExecutable and CreateProcess to force URLs to open in new sessions of a browser.  Oct 18.1999



File Counting
vb6
vb5
vb4-32
FindFirstFile: Determining the Oldest Folder (Recursive)
How to recursively iterate through the file system to determine the oldest folder. Sept 6.2005

FindFirstFile: Fast Directory File Count
Use this tight routine to count the files in a given folder in blistering speed. Uses a passed filespec as the counting parameter. Includes routines to perform attribute-specific counts as well. Sept 4.1997

FindFirstFile: Fastest Tests for Files or Subfolders
Wrapper routines to determine if a specific folder contains either files or subfolders. Dec 20.2004



File & Folder Search

Recursive Searches

Cross-Drive File & Folder Search
vb6
vb5
vb4-32

Enumerating Folders using FindFirstFile and FindNextFile API
API routine recursively load a TreeView control with the folders on a selected drive.

Enumerating Folders using FindFirstFile and FindNextFile API, Advanced
Building on the code from the above page, this method provides for the optional loading of folders for either a single-level or an entire drive, and adds visual identification to the drives and folders with ImageList icons.

FindFirstFile: Determining the Oldest Folder (Recursive)
How to recursively iterate through the file system to determine the oldest folder. Sept 6.2005

FindFirstFile: Fastest Tests for Files or Subfolders
Wrapper routines to determine if a specific folder contains either files or subfolders. Dec 20.2004

FindFirstFile: Recursive File Search (minimal code)
The minimal code required to code a recursive FindFirstFile API routine for a single-drive file search. Nov 5.2001

FindFirstFile: Recursive Search for Folders (minimal code)
The minimal code required to code a recursive FindFirstFile API routine for a single-drive folder search. Nov 5.2001

FindFirstFile: Recursive File Search for Single or Multiple File Types (minimal code)
The minimal code required for a recursive FindFirstFile search across a single-drive for multiple file types. Nov 11.2001

FindFirstFile: Recursive File Search Including/Excluding Single or Multiple File Types (minimal code)
The minimal code required to code a recursive FindFirstFile search across a single-drive for multiple file types, with the option of locating all files matching the file mask, or locating all files not matching the mask. Nov 11.2001

FindFirstFile: Recursive Search for Folders Using a Folder Mask (minimal code)
The minimal code required to code a recursive FindFirstFile search across a single-drive for multiple folders, with the option of locating all folders matching the file mask, or locating all folders not matching the mask. Feb 27.2001

FindFirstFile: Calculating Folder Size, Recursive
Stripping out the non-essential code from our FindFirstFile routines to return just the total bytes in the specified folder and optionally, its subfolders. Mar 30.2002

FindFirstFile: Extract Filename from a Full Path
Small function returning the filename alone from a full path and filename. Feb 11.2001

FindFirstFile: Performance Comparison - FSO vs. API
Herein lies the truth - the FileSystemObject and API compared for file searching Apr 12.2000

FindFirstFile: Comparison of FindFirstFile and SearchTreeForFile
Four very fast, functional routines for file and folder searching. Oct 3.1999

GetPrivateProfileString: Parse IE Favourites Information
Extracting the shortcut name and URL from an IE Favourite. Mar 09.2000

FindFirstFile: Save a Recursive Search of All Drives to Disk
Build on the Recurse methods to grab all the filenames from a system and write them to disk. Oct 8.1999

FindFirstFile: Save a Recursive Search of Specified Drives to Disk
Advanced disk searching using the FindFirstFile recursion methods to grab all the filenames from a system and write them to disk. Oct 8.1999

SearchTreeForFile: Search a Drive to Locate a Specific File
Use this simple API to locate the full path to a specific file. June 12.1999

GetFileVersionInfo: File Search and File Property Info
Recursive file searching that additionally retrieves select file property information.   Nov 29.1999



FindFirst - FindNext Change
vb6
vb5
vb4-32
Creating a Watched Folder with FindFirst/NextChange Notifications
Monitor when the contents of a folder or subfolder have changed.


FindFirst - FindNext URL
vb6
vb5
vb4-32
FindFirstUrlCacheEntry: Delete the IE Cache
Using DeleteUrlCacheEntry to empty the internet cache programmatically. Dec 06.1999

FindFirstUrlCacheEntry: Obtain the Contents of the IE Cache
Find URL and cookie info from your Internet cache. Nov 16.1999



FTP/HTTP
vb6
vb5
vb4-32
FtpFindFirstFile: Connect and Retrieve FTP File Listings
Using the FTP APIs to connect to a site and retrieve its file listing. Dec 17.1999

FtpGetFile: Download Files via FTP
Adding to the FTP demo adding file download ability. Dec 17.1999

DoFileDownload: Download Files Using IE's Download Dialog
Use the Internet Explorer File Download dialog in your application.  Jan 8.2000

DoFileDownload: Customize the IE Download Dialog
Customize the DoFileDownload folder to specify the path and title, and return the download success. Nov 28.2002

FtpFindFirstFile: Download Files via FTP with a Download Progress Callback
How to use callbacks to present a progress bar and file size transferred from a FTP download session.  Oct 27.2001



INI Files
vb6
vb5
vb4-32
vb4-16
vb3
WritePrivateProfileString: Create the 'Kidz Quiz' project
Code to create a child's quiz application, easily extended to cover adults. Aug 24 .1999

GetPrivateProfileString: Parse IE Favourites Information
Extracting the shortcut name and URL from an IE Favourite. Mar 09.2000

WritePrivateProfileString: INI Files - The Basics
Primer on saving and reading data from private ini files. Aug 13 .1999

WritePrivateProfileString: INI Files - Saving Entire Sections
INI section manipulation - saving and restoring an entire list from private ini files. Aug 13 .1999



Owners
vb6
vb5
vb4-32
GetSecurityDescriptorOwner: Local or Remote File or Folder Owner
GetFileSecurity, LookupAccountSid and GetSecurityDescriptorOwner return the owner of a file or a folder on a local or remote machine. Jan 17.2006

NetFileEnum: Get Open File Info from a Specified Machine
Use NetFileEnum to return a listing of open files and owners on remote machines. Apr 5.2003



Paths
vb6
vb5
vb4-32
PathFileExists: A Local/Network File/Folder/Drive Exists Routine
Tests the validity of the file and path on the local file system or on a remote drive that has been mounted to a drive letter. Apr 8.2001

PathIsDirectoryEmpty: Test for Empty Directories
Determines whether or not a specified path is an empty directory. Apr 8.2001

PathIsFileSpec: Test to Determine if String Meets Valid File Spec
Determines whether or not a specified path contains path delimiting characters. Apr 8.2001

PathIsDirectory: Routine To Determine if Path is A Folder
Verifies that a path is a valid directory. Apr 8.2001

PathIsRoot: Determine if Path is Directory Root
Parses a path to determine if it is a directory root. Apr 8.2001

PathIsLFNFileSpec: Determine if Filename is in Long Format
Determines whether or not a file name is in long format. Apr 8.2001

PathIsNetworkPath: Determine if Path is Local
Determines whether a path string represents a local resource. Apr 8.2001

PathIsNetworkPath: Determine if Path Represents a Network Resource
Determines whether a path string represents a network resource. Apr 8.2001

PathIsRelative: Test if Path is Relative vs. Absolute
Searches a path and determines if it is relative. Apr 8.2001

PathIsUNCServerShare: Determine if String is Valid UNC Share Path
Determines if a string is a valid universal naming convention (UNC) share path, \\server\share. Apr 8.2001

PathIsUNCServer: Determine if String is Valid UNC Server Path Only
Determines if a string is a valid UNC (universal naming convention) for a server path only. Apr 8.2001

PathIsUNC: Determine if String is Valid UNC Server/Share Path
Determines if the string is a valid UNC (universal naming convention) for a server and share path. Apr 8.2001

PathIsURL: Determine if String is Valid URL Format
Determines if a string string conforms to a valid URL format. Apr 8.2001

PathMatchSpec: Searches a String Using MS-DOS Wild-Card Match
Searches a string using a DOS wild card match type. April 25.2001

PathFindExtension: File Extension from Local/Remote/IP/UNC Filename
Searches a path for an extension. April 25.2001

PathFindFileName: File Path from Local/Remote/IP/UNC Filename
Searches a path for a file name. April 25.2001

PathFindNextComponent: Parse File Path Components
Parses a path for the next path component. April 25.2001

PathFindNextComponent: Parse String to Obtain Path Components
Recursively parses a path for the next path component. April 25.2001

PathRemoveExtension: Returns Filename with Extension Removed
Removes the file extension from a path, if there is one. April 25.2001

PathStripPath: Removes Path Portion of Fully-qualified Path/Filename
Removes the path portion of a fully qualified path and file. April 25.2001

PathUnquoteSpaces: Removes Wrapping Quotes from Paths/Filenames
Removes quotes from the beginning and end of a path. April 25.2001

PathStripToRoot: Remove All Parts of a Path Except for Root Information
Removes all parts of the path except for the root information. April 25.2001

PathRemoveFileSpec: Remove Trailing Filename/Backslash from Path
Removes the trailing file name and backslash from a path, if it has them. April 25.2001

PathSkipRoot: Parses Path Ignoring Drive or UNC Path
Parses a path, ignoring the drive letter or UNC server/share path parts. April 25.2001

PathStripToRoot: Determine if a Path Contains a Valid Drive Syntax
Indicates whether the passed path contains a valid drive. April 25.2001

PathIsSameRoot: Determine if Paths Share Common Root
Compares two paths to determine if they have a common root component. April 25.2001

PathQuoteSpaces: Returns Quoted Path String if Spaces Found
Searches a path for spaces and encloses the entire path is enclosed in quotation marks if spaces are found. April 25.2001



System
vb6
vb5
vb4-32
Obtaining a Listing of Protected System Files
Find out which system files are protected from replacement or deletion. Apr 18.2004
 


Temporary Files
vb6
vb5
vb4-32
GetTempFileName: Create Temporary Files for Application Use
Use Windows' built-in functions to create working files as needed.  Aug 2.1998


Truncate
vb6
vb5
vb4-32
SetEndOfFile: Delete Records from the End of a Random Access File
Use SetEndOfFile to truncate records from a random access file.  Jan 30.2006


 

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter