Feiqiu's file reading and writing code

Source: Internet
Author: User

Everyone knows that LAN chatInstant Messaging SoftwareIt is the most common thing, so a large number of import of Instant Messaging Software is conducive to LAN chat, feiqiu www.freeeim.com download in determining the ranking of a website, it is necessary not only to analyze the webpage content and structure, but also to analyze the website's instant messaging software. An important factor affecting website rankings is obtaining as many high-quality external instant messaging software as possible, also known as importing instant messaging software.

What is the import of Instant Messaging Software?

 

Feiqiu's file reading and writing code

File Read operations

Static void main (string [] ARGs)
{
String Path = "";
Console. writeline ("Enter the file name of the file to be read, including the path ");
Path = console. Readline ();
If (! File. exists (PATH ))
{
Console. writeline ("the file does not exist ");
Return;
}

Try
{
Filestream file = new filestream (path, filemode. Open );
Byte [] bt = new byte;
File. Read (BT, 0, BT. Length );
String STR = encoding. Default. getstring (BT );
Console. writeline (STR );
Console. Readline ();
}
Catch (system. Exception E)
{
Console. writeline ("An error occurred while reading the file ");
}

}

 

File write operations:

Static void main (string [] ARGs)
{
// Filestream fs1 = file. Create ("test1 ");
// Fs1.close ();
// Console. Readline ();

String Path = "";
String content = "";
Console. writeline ("Enter the file name of the file to be saved, including the path ");
Path = console. Readline ();
Console. writeline ("Enter the content to save ");
Content = console. Readline ();
Try
{
Filestream file = new filestream (path, filemode. Create );
Byte [] bt = encoding. utf8.getbytes (content );
File. Write (BT, 0, BT. Length );
File. Flush ();
}
Catch (system. Exception E)
{
Console. writeline ("An error occurred while creating or writing Files ");

}

 

// Read the file stream

Static void main (string [] ARGs)
{
Console. writeline ("Enter the file name to read, including the path ");
String Path = console. Readline ();
If (! File. exists (PATH ))
{
Console. writeline ("the file does not exist ");
Return;
}

Filestream readstream = new filestream (path, filemode. Open );
Bufferedstream readbuffered = new bufferedstream (readstream );
Byte [] bt = new byte [readbuffered. Length];
Readbuffered. Read (BT, 0, (INT) readbuffered. Length );
Console. writeline (encoding. Default. getstring (BT ));
Readbuffered. Close ();
Console. Readline ();
}

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.