ChangeFilePath - C++ Builder

C++ Builder 参考手册System::SysutilsChangeFilePath


更换路径和文件名当中的路径 (包括盘符和文件夹名),这只是字符串处理函数,与磁盘中是否有这个文件无关,也不会把磁盘中的文件移动位置。

头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:

System::UnicodeString __fastcall ChangeFilePath(const System::UnicodeString FileName, const System::UnicodeString Path);

参数:

  • FileName 路径和文件名,字符串;
  • Path 新的路径,包括盘符和文件夹名,字符串;

返回值:

  • 参数 FileName 当中的路径 (包括盘符和文件夹) 更换为参数 Path 字符串;
  • 更换路径和文件名当中的路径 (包括盘符和文件夹名),这只是字符串处理函数,与磁盘中是否有这个文件无关,也不会把磁盘中的文件移动位置。

例子:替换当前运行的 exe 文件的路径为 C:\ProgramData

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    UnicodeString s = Application->ExeName;
    Memo1->Lines->Add(s);
    s = Sysutils::ChangeFilePath(s, L"C:\\ProgramData");
    Memo1->Lines->Add(s);
}

运行结果:

运行结果

相关:

  • System::Sysutils::ChangeFileExt
  • System::Sysutils::ChangeFilePath
  • System::Sysutils::ExtractFileDir
  • System::Sysutils::ExtractFileDrive
  • System::Sysutils::ExtractFileExt
  • System::Sysutils::ExtractFileName
  • System::Sysutils::ExtractFilePath
  • System::Sysutils::ExtractRelativePath
  • System::Sysutils::ExtractShortPathName
  • System::Sysutils
  • std::_fullpath, std::_tfullpath, std::_wfullpath
  • std::_makepath, std::_tmakepath, std::_wmakepath
  • std::_splitpath, std::_tsplitpath, std::_wsplitpath
  • <cstdlib>

C++ Builder 参考手册System::SysutilsChangeFilePath

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容