ExpandFileName - C++ Builder

2021-11-05  本文已影响0人  玄坴

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


把相对路径转为完整路径

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

System::UnicodeString __fastcall ExpandFileName(const System::UnicodeString FileName);

参数:

返回值:


例子:

#include <System.IOUtils.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    UnicodeString s = Sysutils::ExpandFileName(L"Test.txt");
    Memo1->Lines->Add(s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
    UnicodeString s = Ioutils::TPath::GetDocumentsPath(); // 获取 "我的文档" 文件夹位置
    Sysutils::SetCurrentDir(s); // 设置当前路径为 "我的文档" 文件夹
    s = Sysutils::ExpandFileName(L"Test.txt"); // 相对路径转为完整路径
    Memo1->Lines->Add(s);
}

运行结果:

点击 Button1 运行结果 点击 Button2 运行结果

相关:


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

上一篇 下一篇

猜你喜欢

热点阅读