// PathGetPathRoot.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" using namespace System; using namespace System::IO; void PathGetPathRoot() { // ルートディレクトリ名を取得する String^ stRootName = Path::GetPathRoot( "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\GetPathRootPath\\GetPathRootPath.txt"); // ルートディレクトリ名を表示する Console::WriteLine(stRootName); // DirectoryInfo の新しいインスタンスを生成する DirectoryInfo^ hDirInfo = gcnew DirectoryInfo( "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\GetPathRootPath\\"); // DirectoryInfo からルートディレクトリの DirectoryInfo を取得する DirectoryInfo^ hRootInfo = hDirInfo->Root; // ルートディレクトリ名を表示する Console::WriteLine(hRootInfo->FullName); } int main(array ^args) { PathGetPathRoot(); return 0; }