c++ builder XE4, 10.2 Tokyo > fileIO > 親ディレクトリを取得する > TDirectory::GetParent()
3534 ワード
動作確認
C++ Builder XE4
RAD Studio 10.2 Tokyo Update 2 (追記: 2018/01/09)
あるフォルダパス文字列から一つ上のフォルダパスを取得したい。
参考
http://stackoverflow.com/questions/14639230/directory-path-manipulation-in-delphi
TDirectory::GetParent()を使うようだ。
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <IOUtils.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String path = L"C:\\Users\\user\\Documents\\RAD Studio\\Projects\\00-work";
String upper = TDirectory::GetParent(path);
OutputDebugString(upper.c_str());
}
//---------------------------------------------------------------------------
結果
デバッグ出力: C:\Users\user\Documents\RAD Studio\Projects プロセス Project1.exe (3196)
00-work
がなくなったフォルダパスを取得できた。
Author And Source
この問題について(c++ builder XE4, 10.2 Tokyo > fileIO > 親ディレクトリを取得する > TDirectory::GetParent()), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/e20b645a121a9a25b15f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .