The following code example demonstrates the
This code retrieves file information for Notepad.exe.
Example
В | Copy Code |
---|---|
// file_info.cpp // compile with: /clr using namespace System; using namespace System::IO; int main() { array<String^>^ args = Environment::GetCommandLineArgs(); if (args->Length < 2) { Console::WriteLine("\nUSAGE : file_info <filename>\n\n"); return -1; } FileInfo^ fi = gcnew FileInfo( args[1] ); Console::WriteLine("file size: {0}", fi->Length ); Console::Write("File creation date: "); Console::Write(fi->CreationTime.Month.ToString()); Console::Write(".{0}", fi->CreationTime.Day.ToString()); Console::WriteLine(".{0}", fi->CreationTime.Year.ToString()); Console::Write("Last access date: "); Console::Write(fi->LastAccessTime.Month.ToString()); Console::Write(".{0}", fi->LastAccessTime.Day.ToString()); Console::WriteLine(".{0}", fi->LastAccessTime.Year.ToString()); return 0; } |