Io stream read and write files + SQL replace update field script

Source: Internet
Author: User
// 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 '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.