// DirectoryDelete.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" using namespace System; using namespace System::IO; int main(array ^args) { // Specify the directories you want to manipulate. String^ path1 = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\DeleteDirectory1"; String^ path2 = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\DeleteDirectory2"; String^ path3 = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\DeleteDirectory3"; try { // フォルダを削除する Directory::Delete(path1, true); Console::WriteLine("'{0} を削除しました。'", path1); // ディレクトリ内が空の時だけ削除する (以下のどちらか) Directory::Delete(path2, false); Console::WriteLine("'{0} を削除しました。'", path2); Directory::Delete(path3); // 第 2 引数を省略しても良い Console::WriteLine("'{0} を削除しました。'", path3); } catch (IOException^ e) { Console::WriteLine("プロセスが失敗しました。: {0}", e); } return 0; }