C # get file last Modified date code
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (F.lastwritetime.tostring ());
C # get file last access time code
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (F.lastaccesstime.tostring ());//Last accessed
C # get file creation time code
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (F.creationtime.tostring ());
C # get File size code
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (F.length.tostring ());
C # Get File file Property code
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (f.attributes);
C # File path
FileInfo f = new FileInfo (@ "C:\1.txt");
Console.WriteLine (F.directoryname);C # append file
StreamWriter SW = File.appendtext (Server.MapPath (".") + "\\myText.txt");
Sw. WriteLine ("Chasing the ideal");
Sw. WriteLine ("kzlll");
Sw. WriteLine (". NET Notes ");
Sw. Flush ();
Sw. Close ();
C # Copy files
String Orignfile,newfile;
Orignfile = Server.MapPath (".") + "\\myText.txt";
NewFile = Server.MapPath (".") + "\\myTextCopy.txt";
File.Copy (orignfile,newfile,true);
C # Delete Files
String delfile = Server.MapPath (".") + "\\myTextCopy.txt";
File.delete (Delfile);
C # moving files
String Orignfile,newfile;
Orignfile = Server.MapPath (".") + "\\myText.txt";
NewFile = Server.MapPath (".") + "\\myTextCopy.txt";
File.move (orignfile,newfile); To copy files from one directory to another
FileInfo fi = new FileInfo (path1);
Fi. CopyTo (path2, true);
path1 source file path, path2 destination file path.
Read (2423)| Comments (0)
C # File property read operations and file operations