CSharp examples for File IO:File
Get file information
using System;// www . j a v a2 s . com using System.IO; class FileInspector { public static void Main() { try { FileInfo existingFile = new FileInfo(@"C:\a\main.cs"); Console.WriteLine("File name: " + existingFile.Name); Console.WriteLine("Full file name: " + existingFile.FullName); Console.WriteLine("File length: {0} bytes", existingFile.Length); Console.WriteLine("Date creation time: " + existingFile.CreationTime); Console.WriteLine("Making a copy of MyFairyTale.txt called YourFairytale.txt"); existingFile.CopyTo(@"C:\MyTestFiles\YourFairytale.txt", true); Console.WriteLine("Deleting MyFairytale.txt"); existingFile.Delete(); } catch (IOException exObj) { Console.WriteLine(exObj); } } }