美文网首页
ChangeFilePath - C++ Builder

ChangeFilePath - C++ Builder

作者: 玄坴 | 来源:发表于2021-09-20 08:17 被阅读0次

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

相关文章

网友评论

      本文标题:ChangeFilePath - C++ Builder

      本文链接:https://www.haomeiwen.com/subject/wwpdahtx.html