// Stream reads written files Read files
// Read files
String Strfilecontent = "" ; // Full text of the template file
Try
{
String Strline = "" ; // Content of each line
// You do not need to close the object if you use garbage collection to automatically dispose of this resource. Otherwise, you must close the strfilefullname file path.
Using (Streamreader fileread = New Streamreader (strfilefullname, encoding. Default ))
{
While (Fileread. Peek () > = 0 )
{< br> strline = fileread. readline ();
strfilecontent += strline;
}
}
} Write files
// File write operations
// To ensure the file format, replace some strings
Strfilecontent = Strfilecontent. Replace ( " \ T " , " \ R \ n \ t " );
String Strerrmsg;
String Path;
If ( ! File. exists (strfilefullname ))
{
// Physical path of the strfilefullname File
Path = Strfilefullname. Replace ( " \ Demo.txt " , "" );
// Directoryinfo common instance creation, movement, and enumeration methods
Directoryinfo di = Directory. createdirectory (PATH );
// Create a file in UTF-8 encoding format
Streamwriter SR = File. createtext (strfilefullname );
Sr. Close ();
}
Try
{
System. Io. streamwriter filewrite = New Streamwriter (strfilefullname, False , Encoding. Default );
// Strfilecontent
Filewrite. Write (strfilecontent );
Filewrite. Close ();
}
// Update the replacement fieldUpdate Userinfo Set Url_name =
( Select Replace (Url_name, Substring (Url_name, 0 , 17 ), ' Http: // hanguoji ' ))
Where Substring (Url_name, 0 , 17 ) = ' Http: // localhost '