Read operation:
Method 1:
string str = File.readalltext (@filepath, Encoding.default);
Method 2:
byte [] buffer = file.readallbytes (@filepath); string str = Encoding.Default.GetString (buffer);
Method 3:
string [] buffer = file.readalllines (@filepath, encoding.default); string "" ; foreach (var in buffer) { = str + buf +"\ n";}
Method 4:
New FileStream (@filepath, filemode.openorcreate); byte New byte [1024x7685]; int 0 , buffer. Length); string 0 , length); Fsread.close (); Fsread.dispose () ;
Method 5:
string str =""; using New FileStream (@filepath, filemode.openorcreate,fileaccess.read)) { bytenew byte[1024x7685]; int 0 , buffer. Length); 0 , length);}
Write operation:
Method 1:
File.writealltext (@filepath, str, encoding.default);
Method 2:
byte [] buffer = Encoding.Default.GetBytes (str); File.writeallbytes (@filepath, buffer);
Method 3:
File.writealllines (@filepath, str. Split ('), Encoding.default);
Method 4:
New FileStream (@filepath, FileMode.OpenOrCreate, FileAccess.Write); byte [] buffer =0, buffer. Length); Fswrite.close (); Fswrite.dispose () ;
Method 5:
byte [] buffer = Encoding.Default.GetBytes (str); using New FileStream (@filepath, FileMode.OpenOrCreate, FileAccess.Write)) { 0, buffer. Length);}
Action folder:
CreateDirectory: Creating a Folder
Delete: Deleting a folder
Move: Cut Folder
Exist: Judging whether there is
GetFiles: Gets the full path of all files under the specified directory
Getdirectory: Gets the full path of all folders under the specified directory
File operations in C #