Delphi Files, Directories, Disks, I/O
A. Files B. Directories C. Disks/Drives D. File I/O E. Stream I/O F. Port I/O

See Sections D and E for details of reading or writing files.
(bookmark.gif (183 bytes) Bookmark)

Topic Description Unit
Application.EXEname Filename of the executable application including path information.
Same as ParamStr(0)
bookmark.gif (183 bytes)ASCII Files Text Files in Delphi:  Handling ASCII files from Object Pascal code

ASCII Made Easy:  Manipulating ASCII Files with the Table Component, Delphi Informant, Cary Jensen, June 1999, pp. 26-32

Delphi Import/Export:  Part I: Getting Data into, and out of, ASCII Text Files, Delphi Informant, May 1998

Read a text file backwards

efg's Resource Demo application shows how to use the following file types in resource files:  BMP, ICO, JPG, GIF (requires Anders Melander's TGIFImage), EMF, TXT, AVI, WAV and cursors

Fastest way to search a string in a file

ASCII Codes 

Deepak Shenoy's UseNet Post with file stream example of converting UNIX text to DOS text

Attributes See File Attributes  
Browse for Files See Find Files  
BrowseForFolder Procedure BrowseForFolder is in the FMXUtils.PAS unit of Neil Rubenking's update to PC Magazine utility WMatch32,18 March 1999, which compare directories side-by-side  
Changes Detect changes in files.

File Notification:  VB or Delphi: Which Does COM Automation Best?, Delphi Informant, April 1998.   Discusses functions FindFirstChangeNotification, FindNextChangeNotification, and FindCloseChangeNotification.


Antonio's UseNet Post with "efficient" way to wait for a file (FindFirstChangeNotification, FindNextChangeNotification, FindCloseChangeNotification

ChangeFileExt function ChangeFileExt(const FileName, Extension: string): string;
Changes the extension of a filename.  The new extension can be a an empty string or a period followed by up to three characters

See example with INI Files (below)

Checking if file is in use
Also see ExclusiveIO in File I/O section.
bookmark.gif (183 bytes)Comparing Files TDiff 

Peter Below's (Team B) Usenet Post with sample code using TMemoryStreams and CompareMem to compare files.

Neil Rubenking's PC Magazine utility WMatch32,18 March 1999,
compare directories side-by-side, with complete Delphi source code.  Includes routines MatchAllFiles and MatchDifferentFiles.

Ralph Friedman's (Team B) UseNet Post with sample code using TFileStreams

TFileCompare is a simple class for comparing the contents one file with another. 

A two files identical?  Do a 32 bit CRC-sum?

Compare files probabilistically using CRCs.   See the CRC Lab Report.

For comparison of bitmaps, see Comparison on efg's Delphi Graphics Algorithms:  Image Processing page.

Compression Turobpower's Abbrevia



List of Components

Concat Files Peter Below's UseNet Post with ConcatFiles procedure  
bookmark.gif (183 bytes)CopyFile
// Wrapper for Windows API CopyFile
FUNCTION CopyFile(CONST SourceFile     :  TFilename;
                  CONST DestinationFile:  TFilename):  BOOLEAN;
  RESULT := Windows.CopyFile(pChar(SourceFile),
                             FALSE {Fail if Exists});
END {CopyFile};

Petr Jenicek reports in a UseNet post that when copying files to a network drive,  CopyFile does not return error code ERROR_DISK_FULL but ERROR_ACCESS_DENIED (5).

Copying Files How do I copy a file? (Three examples:  File Streams, Block Read/Write, LZCopy), Borland TI 910D

Copying a directory of a set of files

Copy, Move and Delete Files or Folders in Windows 95 just like Explorer does, Showing flying Files.  Interact with Recent Documents and Recycle Bin.

FileCheck.gif (1195 bytes) Calculate Cyclic Redundancy Codes (CRC-16 or CRC-32) of a file.
efg's CRC FileCheck Lab Report.
Crc.gif (968 bytes) efg's CRC Calculator Lab Report.
DateTimeToFileDate Look for example on efg's Dates and Times page SysUtils
bookmark.gif (183 bytes)DeleteFile function DeleteFile(const FileName:   string):  Boolean;
Erase the specified file.

To delete a Read/Only file, use FileSetAttr to change the attribute to read/write then DeleteFile to delete the file.

- "DeleteFile" example under FindFirst/FindNext/FindClose in Directories
- Calling DeleteFile function, FAQ2591D
- Deleting a directory and all the directory files, Borland FAQ777D
- Recursive delete a group of files and subdirectories,

Deleting Deleting a directory or a set of files
Deleting lines in text file Neil Rubenking's UseNet Post about how to delete a line in an ASCII text file  
Delphi Files Delphi Configuration Files, TI 1105D
Delphi 3 file types with descriptions, TI1552D
"Error reading symbol file" error, FAQ 812D
How can I convert a .dfm file to text and vice versa, FAQ 1151D
Diff Syntax oriented diff tools. Compare two Delphi source file and report all changes. Skip comments. Insensitive to change comments, cases and reformat sources (add/remove spaces or/and empty lines). 

Also see Comparing Files

Directories efg's Directories page  
Drag and Drop with Files, FAQ 529D  
function ExcludeTrailingBackslash(const S: string): string;

Use ExcludeTrailingBackslash to modify a path name (specified by the S parameter) so that it does not end with a backslash character (‘\’). If S does not end in a backslash character, ExcludeTrailingBackslash returns a copy of S.

EXE Date
// Use EXE Date as program version number
    DateTime  :  TDateTime;
    ReturnCode:  INTEGER;
    SearchRec :  TSearchRec;
  ReturnCode := FindFirst(ParamStr(0), faAnyFile, SearchRec);
    IF   ReturnCode = 0
    THEN DateTime := FileDateToDateTime(SearchRec.Time)
    ELSE DateTime := 0
  RESULT := FormatDateTime('mm/dd/yyyy hh:nn:ss', DateTime)
procedure TForm1.Button1Click(Sender: TObject);
  ShowMessage('EXE='    + ParamStr(0) + ', ' +
              'Date = ' + GetEXEDate );
ExpandFileName function ExpandFileName(const FileName: string): string;

ExpandFileName converts the relative file name into a fully qualified path name by merging in the current drive and directory. A fully qualified path name includes the drive letter and any directory and subdirectories in addition to the file name and extension. ExpandFileName does not verify that the resulting fully qualified path name refers to an existing file, or even that the resulting path exists.
ExpandUNCFileName function ExpandUNCFileName(const FileName: string): string;

Expands the given filename to a fully qualified filename. This function is the same as ExpandFileName except that it will return the drive portion of the filename in the format '\\<servername>\<sharename> if that drive is actually a network resource instead of a local resource.


ExtractFileDir function ExtractFileDir(const FileName: string): string;

The resulting string is a directory name suitable for passing to the CreateDir, GetCurrentDir, RemoveDir, and SetCurrentDir functions. This string is empty if FileName contains no drive and directory parts.

ExtractFileDrive function ExtractFileDrive(const FileName: string): string;

ExtractFileDrive returns a string containing the drive portion of a fully qualified path name for the file passed in the FileName. For file names with drive letters, the result is in the form '<drive>'. For file names with a UNC path the result is in the form '\\<servername>\<sharename>'. If the given path contains neither style of path prefix, the result is an empty string.

ExtractFileExt function ExtractFileExt(const FileName: string): string;

Use ExtractFileExt to obtain the extension from a file name.  The resulting string includes the period character that separates the name and extension parts. This string is empty if the given file name has no extension.

IF        UpperCase(ExtractFileExt(OpenPictureDialogAlign.Filename)) = '.JPG'
THEN ...
ExtractFileName function ExtractFileName(const Filename:   string):  string;
Extracts the name and extension parts of the given filename.
ExtractFilePath function ExtractFilePath(const FileName: string): string;

The resulting string is the rightmost characters of FileName, up to and including the colon or backslash that separates the path information from the name and extension. The resulting string is empty if FileName contains no drive and directory parts.

ExtractRelativePath function ExtractRelativePath(const BaseName, DestName: string): string;

Call ExtractRelativePath to convert a fully qualified path name into a relative path name. The DestName parameter specifies file name (including path) to be converted. BaseName is the fully qualified name of the base directory to which the returned path name should be relative.

ExtractShortPathName function ExtractShortPathName(const FileName: string): string;

ExtractShortPathName converts the file name, FileName, to the short 8.3 form. ExtractShortPathName returns an empty string if the file or directory does not exist.

The first parameter, FileName, can be a full path name. For example, ExtractShortPathName would convert the full path name:

C:\Program Files\Borland\Delphi\Bin\Delphi32.exe

to the short form:


FILE FILE of Byte:  See FileSize example (below) reserved keyword
bookmark.gif (183 bytes)File Associations in Registry Peter Below's UseNet Post including RegisterFiletype procedure
Ulli Conrad's UseNet Post

Add two keys to the registry

ATShell is a Delphi 2/3 component for managing file associations. It has the following features: Create association, Remove association, Set association, shell extensions (right click menu) + many more. 

A Windows 98 File Association Un-Mangler.  Dave Jewell begins work on a Windows file association un-mangler, teaching us a lot about the ins and outs of the registry along the way. Plus, he outlines what there is (or isn’t) for programmers to get excited about in Windows 98...   Delphi Magazine, Issue 36, August 98

Windows 98 File Associations, Part 2.  Dave Jewell concludes the construction of his Windows file association un-mangler, so now you can happily undo the damage wreaked by a certain well-known software manufacturer...  Delphi Magazine, Issue 37, Sept 98

bookmark.gif (183 bytes)File Attributes SysUtils Unit:
faReadOnly = $00000001;
faHidden     = $00000002;
faSysFile    = $00000004;
faVolumeID = $00000008;
faDirectory  = $00000010;
faArchive    = $00000020;
faAnyFile    = $0000003F;

Function HasAttr is in the FMXUtils.PAS unit of Neil Rubenking's update to PC Magazine utility WMatch32,18 March 1999, which compare directories side-by-side

File Date and Time

See AlterFileTimeStamp.TXT example.

See efg's Dates and Times page

Section: File Date and Time
Unit PJHFileTimes:

How to Match File Date/Time, Borland TI 719D

File Extensions Registering a file extension and context menu operations
Borland FAQ 2430D

Delphi in a Nutshell, "Forms and Files," p. 2-3

File Extensions

Delphi File Extensions 

File Locking Philippe Ranger's UseNet Post with File Locking Example  
File Management Delphi in a Nutshell, "File Managment," pp. 494-503
- File Input and Output
- Managing Files
- Managing Directories
- Managing Disks
- Managing Filenames
File Mapping efg's UseNet Post with a method used by Neil Rubenking in one of his Delphi PC Magazine utilities to prevent a second instance of an application.  Neil's method uses CreateFileMapping, OpenFIleMapping, MapViewOfFile, UnMapViewOfFile  
File Notification

File Notification:  VB or Delphi: Which Does COM Automation Best?, Delphi Informant, April 1998.

File Properties Peter Below's UseNet Post "File Properties"  
File Variable How can I assign a file variable in a Record, FAQ 1097D  
FileAge D1:
function FileAge(const Filename:  string):  LongInt;

function FileAge(const Filename:  string):  Integer;

Returns the age of the file or -1 if the file does not exist.
Use FileDateToDateTime to convert to a TDateTime value.

Look for example on efg's Dates and Times page

FileDateToDateTime s := FormatDateTime('mm/dd/yyy hh:nn:ss',   // see TSearchRec below
           FileDateToDateTime(SearchRec.Time) );

See EXE Date example above

Borland TI 541D
Look for example on efg's Dates and Times page

FileExists function FileExits(const Filename:   string):  Boolean;
Returns TRUE if specified file exists.

FileExists Using IOResult:   UseNet Post by Sean Kendrick

See example under Append in File I/O

FileGetAttr function FileGetAttr(const FileName: string): Integer;

FileGetAttr returns the attributes of the file as a string of bits. This value is the same as the Attr field of a TSearchRec record. Check for individual attributes with code such as the following:

Attrs := FileGetAttr('MyFile.sys');

if Attrs and faHidden <> 0 then
FileSetAttr('MyFile.sys', Attrs – faHidden);

A return value of -1 indicates that an error occurred.

Garth S. Wilcox's UseNet Post with example of removing read-only attribute.

FileGetDate function FileGetDate(Handle: Integer): Integer;

Use FileGetDate to determine the timestamp of a file given its handle. The return value is -1 if the handle is invalid. The FileDateToDateTime function can be used to convert the returned value to a TDateTime value.

Borland TI 541D
Look for example on efg's Dates and Times page

FileMapping See examples of OpenFileMapping, CreateFileMapping, and UnMapViewOfFile  in RegDet.DPR file in Neil Rubenking's Registry Detective utility from PC Magazine  
FileMode variable var FileMode: Byte;

The FileMode variable determines the access mode to use when typed and untyped files (not text files) are opened using the Reset procedure.

The default FileMode is 2 (Read/Write access). Assigning another value to FileMode causes all subsequent Resets to use that mode. The sysutils unit declares a number of file open mode constants that can be assigned to the FileMode variable.

FileSearch function FileSearch(const Name, DirList: string): string;

FileSearch searches through the directories passed in DirList for a file named Name. DirList is a semicolon delimited set of DOS path names. If FileSearch locates a file matching Name, it returns a string specifying a fully-qualified path name for that file. If no matching file exists, FileSearch returns an empty string.

see also FindFirst/FindNext/FindClose in Directories

FileSetAttr function FileSetAttr(const FileName: string; Attr: Integer): Integer;

FileSetAttr sets the file attributes of the file given by FileName to the value given by Attr. The value of Attr is formed by combining the appropriate file attribute constants, as in the following:

FileSetAttr('MyFile.sys', faReadOnly or faSysFile);

FileSetAttr returns zero if the function was successful. Otherwise the return value is a Windows error code.

Garth S. Wilcox's UseNet Post with example of removing read-only attribute.

Recursive delete a group of files and subdirectories

FileSetDate function FileSetDate(Handle: Integer; Age: Integer): Integer;

FileSetDate sets the DOS date-time stamp of the file given by Handle to the value given by Age. The DateTimeToFileDate function can be used to convert a TDateTime value to a DOS date-time stamp.

The return value is zero if the function was successful. Otherwise the return value is a Windows error code.

How to Match File Date/Time, Borland TI 719D
Look for example on efg's Dates and Times page

bookmark.gif (183 bytes)FileSize Neil Rubenking's FileSizeFromName in the AllFuncs.pas unit of his ColorClue utility.


// Open in Binary mode to use FileSize function
FUNCTION GetFileSize(CONST FileName: STRING): LongInt;
    FileModeSave: BYTE;
    RawFile : FILE OF Byte;
  RESULT := 0; // avoid compiler warning
    FileModeSave := System.FileMode;
    System.FileMode := fmOpenRead + fmShareDenyNone;
    AssignFile (RawFile, FileName);
    Reset (RawFile);
    RESULT := FileSize(RawFile);
    CloseFile (RawFile);
    System.FileMode := FileModeSave
    ShowMessage ('Fatal Error: Cannot open ' + FileName + ' (binary)');
END {GetFileSize};
bookmark.gif (183 bytes)Find Files Opening the "Find Files..." Dialog Using Delphi
by Eddie Shipman

Eddie Shipman's UseNet Post to use Find Files or Folders Dialog

From the Shell:  Dialog Boxes You've Always Needed, Delphi Informant, May 1999
Examples:  Finding Files,  Browsing for Files, ...
Vol. 5, No. 5, pp. 28-36

GetFileDate function FileGetDate(Handle: Integer): Integer;

Use FileGetDate to determine the timestamp of a file given its handle. The return value is -1 if the handle is invalid. The FileDateToDateTime function can be used to convert the returned value to a TDateTime value.

Borland TI 541D

GetFileLastAccessTime When was that file last accessed?

GetFileSize using FindFirst in UseNet Post by Freter

GetFileVersionInfo Steve Shafer's GetBuildInfo procedure in UseNet Post by Peter Below.
(works in D4 or D5 but gives access violation in D3)

When was that file last accessed?

GpHugeFile Encapsulation of Windows file-handling routines that allows work with >2GB files.
Handle Getting a handle on your files, FAQ 534D  
bookmark.gif (183 bytes)INI Files .INI files appear to have a 64 KB limit (removed when using TMemIniFile instead of TIniFile) and 1023 bytes per character string.


EraseSection erase an entire section of INI file
TIniFile in
  IniFiles;    // TIniFile
  Filename: STRING;
  IniFile : TIniFile;
  NewPath : STRING;
  // Update INI file for next time
  Filename := ChangeFileExt(ParamStr(0), '.INI');
  NewPath := ExtractFilePath(OpenPictureDialog.Filename);
  OpenPictureDialog.InitialDir := NewPath;
  IniFile := TIniFile.Create(Filename);
    Inifile.WriteString(KeywordSetup, KeywordDirectory, NewPath)

  // Flush INI cache
  WritePrivateProfileString(NIL, NIL, NIL, pChar(Filename));
Peter Below's comments about TMemIniFile in UseNet Post:  "Internally TMemInifile is just a TStringlist. Each access to a section or item involves linear searches through the stringlist lines, so it tends to get slow if you have thousands of lines. For very large inifiles a better in-memory representation would be a TList of TStringlists, one for each section."  
Peter Below's UseNet Post about changing default printer in D6 including a SendMessage of a WM_WININICHANGE message.
IsLocalFile Thomas Nelvik's UseNet Post with sample code  
JEDI Delphi Jedi Code Library, JclFileUtils.PAS unit  
Links MakeALink and ReadALink functions in the AllFuncs.pas unit of Neil Rubenking's ColorClue utility.  
Long FileNames Using Windows 95 long filenames in command-line parameters
LZCopy - How to copy files in Delphi, Borland TI 910D  
Managing Filenames Delphi in a Nutshell,  pp. 501-503  
Managing Files Delphi in a Nutshell,  pp. 497-499  
MatchesMask function MatchesMask(const Filename, Mask: string): Boolean;

Call MatchesMask to check the Filename parameter using the Mask parameter to describe valid values. A valid mask consists of literal characters, sets, and wildcards.

Each literal character must match a single character in the string. The comparison to literal characters is case-insensitive.

Each set begins with an opening bracket ([) and ends with a closing bracket (]). Between the brackets are the elements of the set. Each element is a literal character or a range. Ranges are specified by an initial value, a dash (-), and a final value. Do not use spaces or commas to separate the elements of the set. A set must match a single character in the string. The character matches the set if it is the same as one of the literal characters in the set, or if it is in one of the ranges in the set. A character is in a range if it matches the initial value, the final value, or falls between the two values. All comparisons are case-insensitive. If the first character after the opening bracket of a set is an exclamation point (!), then the set matches any character that is not in the set.

Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character.

MatchesMask returns True if the string matches the mask. MatchesMask returns false if the string does not match the mask. MatchesMask raises an exception if the mask is syntactically invalid.

Note:  The Filename parameter does not need to be a file name. MatchesMask can be used to check strings against any syntactically correct mask.

bookmark.gif (183 bytes)Memory-Mapped Files "Using Memory-Mapped Files" Delphi 5 Developer's Guide (pp. 362-379) by Teixeria and Pacheco

In Chapter 14 of  Mastering Delphi 5 (pp. 675-677), Marco Cantů explains "Sharing Data with Memory-Mapped Files."

Memory Mapped Files -- Client

Memory Mapped Files -- Server

Patrick Martin's example TBitmap descendant using memory mapped files

MinimizeName function MinimizeName(const Filename: TFileName; Canvas: TCanvas; MaxLen: Integer): TFileName; FileCtrl
New EXE File Header New EXE Headers

Neil Rubenking's TNEHeader Record in his PC Magazine FindOrphans utility, 6 June 2000.

OpenWith dialog Example of calling OpenWith dialog to open a specified file with a selected program.  OpenWithExample.TXT  
Orphaned Files Find and Remove Orphaned Files
PC Magazine Utility FindOrphans by Neil Rubenking 
ParamStr(0) Path and name of the EXE.  Same as Application.EXEname.

- example with INI Files
- example under Append in File I/O

Path Manipulation function PathAddSeparator(const Path: string): string;
function PathAddExtension(const Path, Extension: string): string;
function PathAppend(const Path, Append: string): string;
function PathBuildRoot(const Drive: Byte): string;
function PathCommonPrefix(const Path1, Path2: string): Integer;
function PathCompactPath(const DC: HDC; const Path: string; const Width: Integer;
  CmpFmt: Boolean {$IFDEF SUPPORTS_DEFAULTPARAMS} = True {$ENDIF}): string;
procedure PathExtractElements(const P: string; var Drive, Path, FileName, Ext: string);
function PathExtractFileNameNoExt(const Path: string): string;
function PathGetLongName(const Path: string): string;
function PathGetShortName(const Path: string): string;
function PathIsAbsolute(const Path: string): Boolean;
function PathIsDiskDevice(const Path: string): Boolean;
function PathIsUNC(const Path: string): Boolean;
function PathRemoveSeparator(const Path: string): string;
function PathRemoveExtension(const Path: string): string

Delphi Jedi Code Library (JCL), JCLFileUtils.PAS unit

ProcessPath procedure ProcessPath (const EditText: string; var Drive: Char; var DirPart: string; var FilePart: string);

Call ProcessPath to parse a file name into its drive, path, and file name. Pass the full file name that should be parsed as the EditText parameter. ProcessPath returns the indicated drive, directory, and file name as the Drive, DirPart, and FilePart parameters.

Read-Only Files For Reset, set the FileMode to 0.  For example:

AssignFile(F, Filename);
FileMode := 0;     // set access to read/only

bookmark.gif (183 bytes)Recycle Bin Also see SHFileOperation.

Neil Rubenking's RecycleFile in the AllFuncs.pas unit of his ColorClue utility.

Daniel U. Thibault's DUTUtilsTrash Unit that contains standalone "Trash" (Recycle Bin) utilities, including GetTrashContents, RestoreFromTrash, and EmptyTrash.  Now works under WinNT as well as Win95.  The zip also includes a very simple demo applet.

Sending Files to the Recycle Bin (link broken 3 March 2000)

Bernd Ua's UseNet Post about "How to empty recycle bin?"
Martin Thorsten Heintze's E-mail about how to use SHEmptyRecycleBin 

UseNet Thread about quoting Steve Schafer about Recycle Bin Internals

MS Q136517 "How the Recycle Bin Stores Files"
MS Q171694 "Differences Between the Recycle Bin and the Recycle Folder"

Registry Complete Delphi source code can be found with these PC Magazine utilities by Neil Rubenking:
  • Find Registry Facts Fast:  Registry Detective's search facility can integrate with RegEdit.
  • Safely Edit Your Registry:  RegEdit+ makes editing your Registry less of a hassle and a lot safer.

See examples of reading registry keys under FileDateToDateTime examples

RenameFile function RenameFile(const OldName, NewName:   string):  Boolean;
Renames the specified file or directory.  Wrapper around MoveFile API call.
ScanFile Peter Below's UseNet Post about how to search file for a specified text  
Sharing Peter Below's UseNet Post about sharing files on a network  
ShellAPI Extra Shell Folder locations interface.  Project JEDI Conversion Library by Rudolph Velthuis. 

A complement to Delphi 3.02's ShellAPI.pas (Explorer).  Project JEDI Conversion Library by Daniel U. Thibault. 

A complement to Delphi 3.02's ShlObj.pas (Explorer).  Project JEDI Conversion Library by Daniel U. Thibault. 

ShellExecuteEx Peter Below's UseNet Post "File Properties"  
SHEmptyRecycleBin  Xavier Pacheco's (Team B) UseNet Post about "How to delete the information in the recycle bin"

Bernd Ua's UseNet Post about "How to empty recycle bin?"

bookmark.gif (183 bytes)SHFileOperation Also see Recycle Bin.

Charles Hacker's UseNet Post with SHFileOperation example to copy network drive to local drive

"Using the SHFileOperation Function," Delphi 5 Developer's Guide (pp. 404-406) by Teixeria and Pacheco  (Worked in Windows 98/2000, but failed in original Win 95 -- I likley need an updated Shell32.DLL.)

According to Johannes Berg in a UseNet post, you have to give SHFileOperation the fully qualified filename due to a bug (or feature?) of Windows.

Peter Below's UseNet Post with example of how to delete a folder
Xavier Pacheco's UseNet Post with CopyDirectoryTree procedure

Utilisation de l'API SHFileOperation 

TFileOperation component performs a copy, move, rename or delete operation on a file system object along with the folder animations first introduced in Microsoft Windows 95. It encapsulates the SHFileOperation provided as Shell API in Win32 environment.

Drag and Drop with Files, FAQ 529D

Probing into the Shell's File Operations (Move/Copy/Delete Files)

With this single component, a wrapper around the Windows SHFileOperation API, you can Copy, Rename, Move, Delete, and Recycle any list of files with a single operation. Wayne Niddery's TShellFileOp


SHGetFielInfoCaches Drive Information 

Shortcuts A Quick Way to Shortcuts:  A Component for Creating and Modifying Shortcuts 

Adding shortcuts to Win95/WinNT4 Desktop/StartMenu
Borland TI 1597D

In Chapter 15 of  Mastering Delphi 5 (pp. 708-710), Marco Cantů explains "Creating Shortcuts."

"Slice" "Slice" large files into smaller pieces, then splice them together again.


SWAG Files SWAG (Software Archive Group).  109 various file examples   (requires Reader)

TextFile SWAG.   81 examples

TempFileName Neil Rubenking's TempFileName in the AllFuncs.pas unit of his ColorClue utility.

Also see, GetTempFileName.

Test Files A test file of known size containing ASCII text is often useful to measure actual transfer rates.  The utility "GenTxt" was create for this purpose and can create files up to about 5.9 GB in size (could easily be modified to be even bigger).  See Item B-4 on the Other Projects page.  
TestFilename Test if a string is a valid file name
TFilename TYPE
  TFileName:  STRING[79];  // D1
  TFileName = STRING;  // D2-D3 

  TFilename = TYPE STRING;  // D4, D5  (stronger typing)

TFindFilesDialog TFindFilesDialog and TFindComputerDialog are component wrappers  for two undocumented Windows API functions. The first displays  the standard Find Files dialog and the second the Find Computer dialog.
TIniFile See INI Files  
TOpenDialog See UseNet Post by Matthijs J. Willemstein with an example Dialogs
TRegIniFile Registering a file extension and context menu operations
Borland FAQ 2430D
TSaveDialog   Dialogs
bookmark.gif (183 bytes)TSearchRec
// Search record used by FindFirst, FindNext, and FindClose

TSearchRec =
  Time          :  Integer;
  Size          :  Integer;
  Attr            :   Integer;
  Name        : TFileName;
  ExcludeAttr: Integer;
  FindHandle: THandle;
  FindData    : TWin32FindData;

- FileDateToDateTime (above)
- FindFirst/FindNext/FindLast in Directories

Typed Files My Own Database 
TWin32FindData See TSearchRec
TWin32FindData =
  dwFileAttributes   : DWORD;
  ftCreationTime      : TFileTime;
  ftLastAccessTime : TFileTime;
  ftLastWriteTime     : TFileTime;
  nFileSizeHigh      : DWORD;
  nFileSizeLow       : DWORD;
  dwReserved0       : DWORD;
  dwReserved1       : DWORD;
  cFileName            : array[0..MAX_PATH - 1] of AnsiChar;
  cAlternateFileName: array[0..13] of AnsiChar;

When was that file last accessed?

Using FindFirst and the WIN_32_FIND_DATA structure, Borland TI 1512D

bookmark.gif (183 bytes)UNIX Files UNIX text files only have LFs (line feeds), not CRs (carriage returns). 
LF = #10 = #$0A
CR = #13 = #$0D

UNIX DateTime to Delphi DateTime

Deepak Shenoy's UseNet Post with file stream example of converting UNIX text to DOS text

Mike (TeamB) UseNet Post about parsing UNIX files

Use AdjustLineBreaks to "fix" line ends.  Read the whole file as one string using TFileStream, call AdjustLineBreaks and then save in the converted file.

Waiting for Files Antonio's UseNet Post with "efficient" way to wait for a file (FindFirstChangeNotification, FindNextChangeNotification, FindCloseChangeNotification  
WM_DROPFILES Drag and Drop with Files, FAQ 529D  
Working with Files

"Working with Files," Delphi 5 Developer's Guide, Chapter 12, by Teixeria and Pacheco

Zero-length file Here's a trick way to create a zero-length file with a single statement:
TFileStream.Create(ExtractFilePath(ParamStr(0)) + 
                   'ZeroLength.DAT', fmCreate).Destroy;
Zipped Files InZip performs much the same function as the Windows Find facility, but instead finds files matching your search criteria inside Zip files. If you zip files and can't remember in which zip file they are you will find InZip indispensable. 

  27 Aug 2005

 19 Apr 1999