// FileGetAttributes.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" using namespace System; using namespace System::IO; using namespace System::Text; int main(array ^args) { String^ path = "C:\\MyFolder\\Homepage\\public_html\\Cprpr\\GetAttributesFile\\GetAttributesFile.txt"; // Create the file if it exists. if ( !File::Exists( path ) ) { File::Create( path ); } if ( (File::GetAttributes( path ) & FileAttributes::Hidden) == FileAttributes::Hidden ) { // Show the file. File::SetAttributes( path, FileAttributes::Archive ); Console::WriteLine( "The {0} file is no longer hidden.", path ); } else { // Hide the file. File::SetAttributes( path, static_cast(File::GetAttributes( path ) | FileAttributes::Hidden) ); Console::WriteLine( "The {0} file is now hidden.", path ); } return 0; }