A function of file manipulation is also provided in BCB, the functions of these functions are roughly the same as those described earlier, but these functions are closely related to BCB and can use data types such as the ansistring in BCB, which is the most convenient way to file operations in BCB, and I'll introduce this file operation in detail below.
In the BCB provided by this set of file operation functions, can be divided into three types, namely: 1, File name functions, 2, File management functions, 3, file I/O functions.
1. File name function
The filename function can operate on the name of the file, the subdirectory, the drive, and the extension. The following table lists these functions and their functions.
Function description
Expandfilename () returns the full path of the file (including drive, path)
Extractfileext () Extract the extension from the file name
Extractfilename () Extract filename without path from file name
Extractfilepath () Extract path name from file name
Extractfiledir () Extract the directory name from the file name
Extractfiledrive () Extract the drive name from the file name
Changefileext () Change the file name extension
Expanduncfilename () returns the full path to the file containing the network drive
Extractrelativepath () Extract relative path information from the file name
Extractshortpathname () Converts the file name to DOS 8 3 format
Matchesmask () checks whether the file matches the specified file name format
Here's a description of these functions:
⑴expandfilename ()
Prototype: extern PACKAGE ansistring __fastcall expandfilename (const ansistring FileName);
Function: Returns the full path of the file (including drive, path)
Parameters: FileName: filename to be processed
Example: ShowMessage (Expandfilename (Application->exename));//Display your program file name, such as C:\MyBCB\Sample1.EXE