ChangeFilePath - C++ Builder

C++ Builder 參考手冊 ? System::Sysutils ? ChangeFilePath


更換路徑和文件名當中的路徑 (包括盤符和文件夾名),這只是字符串處理函數,與磁盤中是否有這個文件無關,也不會把磁盤中的文件移動位置。

頭文件:#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::Sysutils ? ChangeFilePath

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容