A quanto pare la classe System.IO non appartiene alla libreria standard C++, ma è roba Microsoft .NET.
Comunque, se ti può servire, ecco un esempio (preso dall'help in linea di
Visual C++ 2005 Express Edition) di utilizzo per verificare/impostare l'attributo nascosto di un certo file:
- Codice:
using namespace System;
using namespace System::IO;
using namespace System::Text;
int main()
{
String^ path = "c:\\temp\\MyTest.txt";
// Delete 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<FileAttributes>(File::GetAttributes( path ) | FileAttributes::Hidden) );
Console::WriteLine( "The {0} file is now hidden.", path );
}
}
Altro esempio che utilizza la classe FileInfo per conoscere nomi e dimensione dei file in una directory:
- Codice:
// The following example displays the names and sizes
// of the files in the specified directory.
using namespace System;
using namespace System::IO;
int main()
{
// Make a reference to a directory.
DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" );
// Get a reference to each file in that directory.
array<FileInfo^>^fiArr = di->GetFiles();
// Display the names and sizes of the files.
Console::WriteLine( "The directory {0} contains the following files:", di->Name );
System::Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
while ( myEnum->MoveNext() )
{
FileInfo^ f = safe_cast<FileInfo^>(myEnum->Current);
Console::WriteLine( "The size of {0} is {1} bytes.", f->Name, f->Length );
}
}