// FileDelete.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" using namespace System; using namespace System::IO; int main(array<System::String ^> ^args) { String^ path = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\DeleteFile\\DeleteFileFrom\\DeleteFileFrom.txt"; String^ path2 = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\DeleteFile\\DeleteFileTo\\DeleteFileTo.txt"; try { StreamWriter^ sw = File::CreateText(path); if (sw) delete (IDisposable^)sw; // Ensure that the target does not exist. File::Delete(path2); // Copy the file. File::Copy(path, path2); Console::WriteLine("{0} was copied to {1}.", path, path2); // Delete the newly created file. File::Delete(path2); Console::WriteLine("{0} was successfully deleted.", path2); } catch ( Exception^ e ) { Console::WriteLine("The process failed: {0}", e); } return 0; }