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