Delphi 获取指定文件的驱动器名, 文件夹名, 路径名, 文件名
2013-04-29 00:37
956 查看
var fullFileName : string; begin // Set up a full file name with drive and path fullFileName := 'C:\Program Files\Borland\Delphi7\Projects\Unit1.dcu'; // Show the component parts of this full name ShowMessage('Drive = '+ExtractFileDrive (fullFileName)); ShowMessage('Dir = '+ExtractFileDir (fullFileName)); ShowMessage('Path = '+ExtractFilePath (fullFileName)); ShowMessage('Name = '+ExtractFileName (fullFileName)); ShowMessage('Ext = '+ExtractFileExt (fullFileName)); end;
Drive = C: Dir = C:\Program Files\Borland\Delphi7\Projects Path = C:\Program Files\Borland\Delphi7\Projects\ Name = Unit1.dcu Ext = .dcu
//获取应程序文件的路径
ExtractFilePath(Application.ExeName);
var oldName, newName : string; begin // Try to rename the current Unit1.dcu to Uni1.old oldName := 'Unit1.dcu'; newName := ChangeFileExt(oldName, '.new'); // Show the old and new values ShowMessage('Old name = '+oldName); ShowMessage('New name = '+newName); end;
Old name = Unit1.dcu New name = Unit1.new
var selectedFile : string; drive : char; path, fileName : string; begin // Ask the user to select a file if PromptForFileName(selectedFile) then begin // Display this full file/path value ShowMessage('Selected file = '+selectedFile); // Split this full file/path value into its constituent parts ProcessPath(selectedFile, drive, path, fileName); ShowMessage('drive = '+drive); ShowMessage('path = '+path); ShowMessage('fileName = '+fileName); end; end;
{ The user selects C:\Files\data.txt and hits OK } Selected file = C:\Files\data.txt drive = C path = \Files filename = data.txt
http://www.delphibasics.co.uk/index.html
相关文章推荐
- delphi 获取指定文件路径中的文件名及扩展名
- VC-获取文件夹中的指定类型的所有文件名和文件大小
- 加载上传图片,获取文件名、文件路径并保存到程序的文件夹中
- Asp.net 获取指定目录下的后缀名为".doc" 的所有文件名和文件路径
- .NET中获取指定文件夹下所有文件的全路径
- C# 打开以对话框,获取文件夹路径 、文件的路径、文件名
- 获取项目加载根路径,得到文件夹下的所有指定后缀文件名列表
- php文件操作小结(删除指定文件/获取文件夹下的文件名/读取文件夹下图片名)
- .net中打开对话框,获取文件夹路径、文件的路径以及文件名
- 获取指定目录下指定类型所有文件的全路径及文件名
- java获取指定路径下的所有文件夹和文件名称路径
- php 遍历文件夹及文件,获取文件名和文件路径存入数据库中
- C#获取文件名 文件路径 文件夹路径
- Delphi中获取文件夹路径的三种方式 和实现文件复制
- 获取指定路径下的所有文件名以及读取配置文件
- C++获取指定文件夹下的所有文件名(或路径)
- C++获取指定文件夹下的所有文件名(或路径)
- C++获取某路径下所有文件名,ifstream打开某路径下的指定文件
- 获取指定文件夹的文件路径
- C#控制台基础 获取指定文件夹下的所有文件的全路径(并不能获得文件夹下的文件夹的路径)