// C # Write/read the text file string fileName = @ "c:/111.txt ";
StreamReader sr = new StreamReader (fileName); string str = sr. readLine (); sr. close (); StreamWriter rw = File. createText (Server. mapPath (". ") +" // myText.txt ");
Rw. WriteLine ("write ");
Rw. WriteLine ("abc ");
Rw. WriteLine (". NET notes ");
Rw. Flush ();
Rw. Close (); // open a text file
StreamReader sr = File. OpenText (Server. MapPath (".") + "// myText.txt ");
StringBuilder output = newStringBuilder ();
String rl;
While (rl = sr. ReadLine ())! = Null)
{
Output. Append (rl + "");
} LblFile. Text = output. ToString ();
Sr. Close (); // C # append an object
StreamWriter sw = File. AppendText (Server. MapPath (".") + "// myText.txt ");
Sw. WriteLine ("Chasing ideals ");
Sw. WriteLine ("kzlll ");
Sw. WriteLine (". NET notes ");
Sw. Flush ();
Sw. Close (); // C # copy an object
String OrignFile, NewFile;
OrignFile = Server. MapPath (".") + "// myText.txt ";
NewFile = Server. MapPath (".") + "// myTextCopy.txt ";
File. Copy (OrignFile, NewFile, true); // C # delete an object
String delFile = Server. MapPath (".") + "// myTextCopy.txt ";
File. Delete (delFile); // C # Move a File
String OrignFile, NewFile;
OrignFile = Server. MapPath (".") + "// myText.txt ";
NewFile = Server. MapPath (".") + "// myTextCopy.txt ";
File. Move (OrignFile, NewFile); // C # create a directory
// Create the directory c:/sixAge
DirectoryInfod = Directory. CreateDirectory ("c: // sixAge ");
// D1 points to c:/sixAge/sixAge1
DirectoryInfod1 = d. CreateSubdirectory ("sixAge1 ");
// D2 points to c:/sixAge/sixAge1/sixAge1_1
DirectoryInfod2 = d1.CreateSubdirectory ("sixAge1_1 ");
// Set the current directory to c:/sixAge
Directory. SetCurrentDirectory ("c: // sixAge ");
// Create the directory c:/sixAge/sixAge2
Directory. CreateDirectory ("sixAge2 ");
// Create the directory c:/sixAge/sixAge2/sixAge2_1
Directory. CreateDirectory ("sixAge2 // sixAge2_1 ");