c++ builder XE4, 10.2 Tokyo > fileIO > 親ディレクトリを取得する > TDirectory::GetParent()


動作確認
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がなくなったフォルダパスを取得できた。