ChangeFilePath - C++ Builder

C++ Builder 参考手册 ➙ System::Sysutils ➙ ChangeFilePath


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

头文件:#include
命名空间: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

C++ Builder 参考手册 ➙ System::Sysutils ➙ ChangeFilePath

你可能感兴趣的:(ChangeFilePath - C++ Builder)