企业标准型手机网站wordpress授权登录
web/
2025/10/2 14:44:34/
文章来源:
企业标准型手机网站,wordpress授权登录,企业在线购物网站建设,黄南网站建设System.SysUtils.AnsiCompareFileName
根据当前语言环境比较文件名。 在 Windows 下不区分大小写#xff0c;在 MAC OS 下区分大小写。 在不使用多字节字符集 (MBCS) 的 Windows 区域设置下#xff0c;AnsiCompareFileName 与 AnsiCompareText 相同。在 MAC OS 和 Linux 下在 MAC OS 下区分大小写。 在不使用多字节字符集 (MBCS) 的 Windows 区域设置下AnsiCompareFileName 与 AnsiCompareText 相同。在 MAC OS 和 Linux 下AnsiCompareFileName 与 AnsiCompareStr 相同。 beginif SameFileName(D:\ceshi\新建文件夹\ceshi.txt, D:\ceshi\新建文件夹\ceshi.txt) thenMemo1.Lines.Add(文件名相同);//输出 文件名相同 if AnsiCompareFileName(ceshi.txt, CESHI.txt) 0 thenMemo1.Lines.Add(相等Windows下不区分大小写)elseMemo1.Lines.Add(不相等);//输出 相等Windows下不区分大小写
end;System.SysUtils.AnsiLowerCaseFileName
将文件名转换为小写。
beginMemo1.Lines.Add(AnsiLowerCaseFileName(CESHI.txt));//输出 ceshi.txt
end;System.IOUtils.TPath.ChangeExtension
class function ChangeExtension(const Path, Extension: string): string;更改给定路径指示的文件或目录的扩展名。
beginMemo1.Lines.Add(TPath.ChangeExtension(C:\Users\Administrator\Desktop\ceshi.txt, xml));//输出 C:\Users\Administrator\Desktop\ceshi.xml
end;System.SysUtils.ChangeFileExt
function ChangeFileExt(const FileName, Extension: string): string;更改文件名的扩展名。
beginMemo1.Lines.Add(ChangeFileExt(ceshi.txt, .xml));//输出 ceshi.xml
end;System.SysUtils.ChangeFilePath
更改文件名的路径。
beginMemo1.Lines.Add(ChangeFilePath(C:\Users\Administrator\Desktop\ceshi.txt, D:\));//输出 D:\ceshi.txt
end;System.SysUtils.DirectoryExists
判断指定目录是否存在。
beginif DirectoryExists(D:\ceshi) thenMemo1.Lines.Add(文件目录存在)elseMemo1.Lines.Add(文件目录不存在);
end;System.IOUtils.TPath.Combine
组合两个路径字符串。
beginMemo1.Lines.Add(TPath.Combine(D:\ceshi\新建文件夹, 新建文件夹 (2)));//输出 D:\ceshi\新建文件夹\新建文件夹 (2)
end;System.IOUtils.TPath.DriveExists
检查给定路径中使用的驱动器号是否实际存在。
varvPath: string;
beginvPath : D:\ceshi2;if TPath.DriveExists(vPath) thenbeginMemo1.Lines.Add(驱动器号存在);if not DirectoryExists(vPath) thenMemo1.Lines.Add(文件目录不存在);end;
end;System.SysUtils.ExcludeTrailingBackslash
返回不带尾部分隔符的路径名。
beginMemo1.Lines.Add(ExcludeTrailingBackslash(D:\ceshi\新建文件夹\));//输出 D:\ceshi\新建文件夹
end;System.SysUtils.ExcludeTrailingPathDelimiter
返回不带尾部分隔符的路径名。
与 ExcludeTrailingBackslash 相同。
System.SysUtils.ExpandFileName
返回相对文件名的完整路径名。
begin//相对于程序运行路径的完整路径Memo1.Lines.Add(ExpandFileName(新建文件夹\ceshi));//输出 D:\Project1\Win32\Debug\新建文件夹\ceshi
end;System.SysUtils.ExpandFileNameCase
返回区分大小写的文件系统上相对文件名的完整路径名。
在 Windows 下与 ExpandFileName 相同。在 MAC OS 和 Linux 下查找文件
uses System.TypInfo;varvMatch: TFilenameCaseMatch;
beginMemo1.Lines.Add(ExpandFileNameCase(ceshi.txt, vMatch));//输出 C:\Users\Administrator\Documents\Embarcadero\Studio\Projects\Win32\Debug\ceshi.txtMemo1.Lines.Add(GetEnumName(TypeInfo(TFilenameCaseMatch), Ord(vMatch)));//输出 mkNone
end;System.SysUtils.ExpandUNCFileName
如果合适以 UNC 格式返回文件名的完整路径。
begin//在“网络位置”中Memo1.Lines.Add(ExpandUNCFileName(ceshi.txt));//输出 \\192.168.1.1\ceshi\ceshi.txt
end;System.SysUtils.ExtractFileDir
从文件名中提取驱动器和目录部分。
beginMemo1.Lines.Add(ExtractFileDir(D:\ceshi\新建文件夹\ceshi.txt));//输出 D:\ceshi\新建文件夹
end;System.SysUtils.ExtractFileDrive
返回文件名的驱动器部分。
beginMemo1.Lines.Add(ExtractFileDrive(D:\ceshi\新建文件夹\ceshi.txt));//输出 D:
end;System.SysUtils.ExtractFileExt
返回文件名的扩展名部分。
beginMemo1.Lines.Add(ExtractFileExt(ceshi.txt));//输出 .txtMemo1.Lines.Add(ExtractFileExt(D:\ceshi\新建文件夹\ceshi.txt));//输出 .txt
end;System.SysUtils.ExtractFileName
提取文件名的名称和扩展名部分。
beginMemo1.Lines.Add(ExtractFileName(ceshi.txt));//输出 ceshi.txtMemo1.Lines.Add(ExtractFileName(D:\ceshi\新建文件夹\ceshi.txt));//输出 ceshi.txt
end;System.SysUtils.ExtractFilePath
返回文件名的驱动器和目录部分。
beginMemo1.Lines.Add(ExtractFilePath(ceshi.txt));//输出 Memo1.Lines.Add(ExtractFilePath(D:\ceshi\新建文件夹\ceshi.txt));//输出 D:\ceshi\新建文件夹\
end;System.SysUtils.ExtractRelativePath
返回相对于特定基目录的相对路径名。
begin//路径需要带“\”否则返回错误ExtractRelativePath(D:\ceshi\新建文件夹\, D:\ceshi\新建文件夹 (2)\);//输出 ..\新建文件夹 (2)\
end;System.SysUtils.ExtractShortPathName
将文件名转换为简短的8.3格式。
begin//文件必须存在才返回Memo1.Lines.Add(ExtractShortPathName(C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\bds.exe));//输出 C:\PROGRA~2\EMBARC~1\Studio\22.0\bin\bds.exe
end;System.IOUtils.TPath.GetAttributes
class function GetAttributes(const Path: string; FollowLink: Boolean True): TFileAttributes;返回文件或目录属性。
uses System.IOUtils, System.TypInfo;varvAttributes: TFileAttributes;vAttrib: TFileAttribute;
beginvAttributes : TPath.GetAttributes(D:\ceshi\新建文件夹\);for vAttrib in vAttributes doMemo1.Lines.Add(GetEnumName(TypeInfo(TFileAttribute), Ord(vAttrib)));//输出 faDirectoryvAttributes : TPath.GetAttributes(D:\ceshi\新建文件夹\ceshi.txt);for vAttrib in vAttributes doMemo1.Lines.Add(GetEnumName(TypeInfo(TFileAttribute), Ord(vAttrib)));//输出 GetAttributes
end;System.IOUtils.TPath.GetDirectoryName
提取文件名的驱动器和目录部分。
beginMemo1.Lines.Add( TPath.GetDirectoryName(D:\ceshi\新建文件夹\ceshi.txt));//输出 D:\ceshi\新建文件夹
end;System.IOUtils.TPath.GetExtendedPrefix
返回给定路径的扩展前缀类型。
beginTPath.GetExtendedPrefix(D:\ceshi\新建文件夹\);//输出 pptNoPrefix
end;System.IOUtils.TPath.GetExtension
提取文件名的扩展名部分。
beginMemo1.Lines.Add(TPath.GetExtension(ceshi.txt));//输出 .txtMemo1.Lines.Add(TPath.GetExtension(D:\ceshi\新建文件夹\ceshi.txt));//输出 .txt
end;System.IOUtils.TPath.GetFileName
提取文件名的名称和扩展名部分。
beginMemo1.Lines.Add(TPath.GetFileName(ceshi.txt));//输出 ceshi.txtMemo1.Lines.Add(TPath.GetFileName(D:\ceshi\新建文件夹\ceshi.txt));//输出 ceshi.txt
end;System.IOUtils.TPath.GetFileNameWithoutExtension
提取文件名的名称部分不带扩展名。
beginMemo1.Lines.Add(TPath.GetFileNameWithoutExtension(ceshi.txt));//输出 ceshiMemo1.Lines.Add(TPath.GetFileNameWithoutExtension(D:\ceshi\新建文件夹\ceshi.txt));//输出 ceshi
end;System.IOUtils.TPath.GetFullPath
返回给定路径的绝对路径。
beginMemo1.Lines.Add(TPath.GetFullPath(ceshi.txt));//输出 C:\Users\Administrator\Documents\Embarcadero\Studio\Projects\Win32\Debug\ceshi.txt
end;System.IOUtils.TPath.GetGUIDFileName
生成可用作唯一文件名的新 GUID。
beginMemo1.Lines.Add(TPath.GetGUIDFileName);//输出 17DC1DDB8C334D61A5499597CEC22D5E
end;System.IOUtils.TPath.GetHomePath
返回用户的主路径。
beginMemo1.Lines.Add(TPath.GetHomePath);//输出 C:\Users\Administrator\AppData\Roaming
end;System.IOUtils.TPath.GetRandomFileName
生成新的随机文件名。
beginMemo1.Lines.Add(TPath.GetRandomFileName);//输出 0EpRoGU5.7O1
end;System.IOUtils.TPath.GetTempFileName
生成一个唯一的临时文件。
varvFile: string;
beginvFile : TPath.GetTempFileName;Memo1.Lines.Add(vFile);//输出 C:\Users\Administrator\AppData\Local\Temp\tmp8F56.tmp//不使用时删除DeleteFile(vFile);
end;System.IOUtils.TPath.GetTempPath
返回系统临时目录的路径。
beginMemo1.Lines.Add(TPath.GetTempPath);//输出 C:\Users\Administrator\AppData\Local\Temp\
end;System.IOUtils.TPath.HasExtension
检查给定文件名是否有扩展名部分。
beginif TPath.HasExtension(ceshi.txt) thenMemo1.Lines.Add(包含扩展名);//输出 包含扩展名 if not TPath.HasExtension(D:\ceshi\新建文件夹\) thenMemo1.Lines.Add(不包含扩展名);//输出 不包含扩展名
end;System.IOUtils.TPath.HasValidFileNameChars
class function HasValidFileNameChars(const FileName: string; const UseWildcards: Boolean): Boolean;检查给定文件名是否仅包含允许的字符。
UseWildcards 指定通配符是否被视为有效的文件名字符例如星号或问号。
beginif not TPath.HasValidFileNameChars(ceshi.txt, False) thenMemo1.Lines.Add(包含特殊字符);//输出 包含特殊字符 if TPath.HasValidFileNameChars(ceshi*.txt, True) thenMemo1.Lines.Add(包含通配符字符);//输出 包含通配符字符
end;System.IOUtils.TPath.HasValidPathChars
class function HasValidPathChars(const Path: string; const UseWildcards: Boolean): Boolean;检查给定路径字符串是否仅包含允许的字符。
UseWildcards 指定通配符是否被视为有效的文件名字符例如星号或问号。
beginif not TPath.HasValidPathChars(D:\ceshi\新建文件夹, False) thenMemo1.Lines.Add(包含特殊字符);//输出 包含特殊字符 if TPath.HasValidPathChars(D:\ceshi\新建文件夹*, True) thenMemo1.Lines.Add(包含通配符字符);//输出 包含通配符字符
end;System.SysUtils.IncludeTrailingBackslash
返回带尾部分隔符的路径名。在 Windows 上为 \否则为 /。 注意包含此函数只是为了向后兼容。应改用 System.SysUtils.IncludeTrailingPathDelimiter。 System.SysUtils.IncludeTrailingPathDelimiter
function IncludeTrailingPathDelimiter(const S: string): string;返回带尾部分隔符的路径名。在 Windows 上为 \否则为 /。
如果已经以尾部分隔符结尾则原样返回否则附加分隔符。
procedure TForm1.Button1Click(Sender: TObject);
beginMemo1.Lines.Add(IncludeTrailingPathDelimiter(D:\ceshi\新建文件夹));//输出 D:\ceshi\新建文件夹\
end;System.IOUtils.TPath.IsDriveRooted
class function IsDriveRooted(const Path: string): Boolean;检查给定路径是否是绝对路径并以驱动器号开头。 在 POSIX 上始终返回 false因为没有驱动器根。 beginif TPath.IsDriveRooted(D:\ceshi\新建文件夹\) thenMemo1.Lines.Add(绝对路径);//输出 绝对路径if TPath.IsDriveRooted(D:) thenMemo1.Lines.Add(绝对路径);//输出 绝对路径
end;System.IOUtils.TPath.IsExtendedPrefixed
class function IsExtendedPrefixed(const Path: string): Boolean;检查给定路径是否包含扩展前缀。
以 \\?\或 \\?\UNC\ 为前缀的路径是 Windows 特有的长度可以非常大并且不限于 255 个字符 (MAX_PATH)。在路径前面加上 \\?\ 可以解决长度超过 255 个字符问题。\\?\ 告诉 Windows API 禁用所有字符串解析并将其后面的字符串发送到文件系统。可以超出 Windows API 强制执行的 MAX_PATH 限制。 在 POSIX 上始终返回 false因为没有扩展前缀。 beginif TPath.IsExtendedPrefixed(\\?\D:\ceshi\新建文件夹) thenMemo1.Lines.Add(包含扩展前缀);//输出 包含扩展前缀
end;System.SysUtils.IsPathDelimiter
function IsPathDelimiter(const S: string; Index: Integer): Boolean;指示字符串中指定位置的字符是否为路径分隔符。在 Windows 上为 \否则为 /。位置索引从 1 开始。
beginif IsPathDelimiter(D:\ceshi\新建文件夹, 3) thenMemo1.Lines.Add(第3个字符为路径分隔符\);//输出 第3个字符为路径分隔符\
end;System.IOUtils.TPath.IsPathRooted
检查给定路径是否是绝对路径。
beginif TPath.IsPathRooted(D:\ceshi\新建文件夹\) thenMemo1.Lines.Add(绝对路径);//输出 绝对路径if TPath.IsPathRooted(\ceshi\新建文件夹) thenMemo1.Lines.Add(没有驱动器号开头的绝对路径);//输出 没有驱动器号开头的绝对路径if not TPath.IsPathRooted(ceshi\新建文件夹) thenMemo1.Lines.Add(相对路径);//输出 绝对路径
end;System.IOUtils.TPath.IsUNCPath
检查给定路径是否为 UNC 格式。UNC 格式路径以两个反斜杠字符为前缀例如\\computer\folder。
beginif TPath.IsUNCPath(\\192.168.1.1\ceshi) thenMemo1.Lines.Add(UNC格式);//输出 UNC格式if not TPath.IsUNCPath(\\192.168.1.1\ceshi) thenMemo1.Lines.Add(不正确的UNC格式);//输出 不正确的UNC格式
end;System.IOUtils.TPath.IsUNCRooted
检查给定路径是否是 UNC 根路径。 在 POSIX 上始终返回 false因为没有扩展前缀。 procedure TForm1.Button1Click(Sender: TObject);
beginif TPath.IsUNCRooted(\\192.168.1.1\ceshi) thenMemo1.Lines.Add(UNC根路径);//输出 UNC根路径if TPath.IsUNCRooted(\\192.168.1.1\ceshi) thenMemo1.Lines.Add(UNC根路径);//输出 UNC根路径
end;System.IOUtils.TPath.IsValidFileNameChar
检查文件名字符串中是否允许使用给定字符。 Windows 中特殊字符 #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #30, #31, , *, /, :, , , ?, \, | MacOS, iOS, Android, Linux 中特殊字符 #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #30, #31, / , ~. beginif not TPath.IsValidFileNameChar(*) thenMemo1.Lines.Add(文件名中不能使用);//输出 文件名中不能使用
end;System.IOUtils.TPath.IsValidPathChar
检查路径字符串中是否允许使用给定字符。
beginif not TPath.IsValidPathChar(|) thenMemo1.Lines.Add(路径中不能使用);//输出 路径中不能使用
end;Vcl.FileCtrl.MinimizeName
function MinimizeName(const Filename: TFileName; Canvas: TCanvas; MaxLen: Integer): TFileName;获取可以在有限大小的在画布上绘制的文件名和路径的缩写名称。 缩短 Filename使其可以在 MaxLen 长度限制内绘制。用点替换文件名路径部分中的目录直到生成的名称符合指定的像素长度。Canvas 是要呈现缩写名称的画布用于确定字体规格。
rebeginMemo1.Lines.Add(MinimizeName(D:\ceshi\新建文件夹\ceshi.txt, Self.Canvas, 150));//输出 D:\...\新建文件夹\ceshi.txt
end;System.SysUtils.SameFileName
根据当前区域设置比较文件名。
与 AnsiCompareFileName 相同。
System.IOUtils.TPath.SetAttributes
class procedure SetAttributes(const Path: string; const Attributes: TFileAttributes);设置文件或目录属性。
procedure TForm1.Button1Click(Sender: TObject);
begin//设置文件为只读TPath.SetAttributes(D:\ceshi\新建文件夹\ceshi.txt, [TFileAttribute.faReadOnly, TFileAttribute.faHidden]);//设置目录为隐藏TPath.SetAttributes(D:\ceshi\新建文件夹, [TFileAttribute.faHidden]);
end;System.IOUtils.TFile.CreateSymLink
class function CreateSymLink(const Link, Target: string): Boolean;创建符号链接。 注意调用CreateSymLink时目标文件或目录必须存在。 在 Windows Vista 及更高版本的 Windows 上使用。 procedure TForm1.Button1Click(Sender: TObject);
begin//相当于CMD命令 mklink D:\SymLink D:\ceshi\新建文件夹TFile.CreateSymLink(D:\SymLink, D:\ceshi\新建文件夹);
end;
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/85665.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!