tailieunhanh - Professional ASP.NET 1.0 Special Edition- P30
Professional Special Edition- P30:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | Do While Not name Is Nothing name br name Loop body html Here we use the method to open up the file. If successful this method returns a StreamReader object that can be used to read characters not bytes from the file. Our code uses the ReadLine method which reads all characters up to the next carriage return line feed. Although this method reads the carriage return line feeds from the stream they are not returned as part of the return string. When the end of the file is reached a Null string is returned. We check for this and use it to terminate our while loop. Calling the Close method closes the file. To ensure that our code remains scalable we should always close files as soon as possible. The following code shows how we can create a new text file and write a few lines to it @ Page Language VB @ Import Namespace Dim books As StreamWriter books Professional Professional C Here we use the method to create a new file. This method returns a Streamwriter object that we can use to write data to the file. Then we call the WriteLine method of the object which is inherited from the base class Textwriter and output the names of the two books. Finally we call the Close method to close the connection to the file. Once we ve written code to read or write data from a backing store such as the file system using the StreamReader or Streamwriter classes we can easily read and write character data from other backing stores such as memory buffers or network connections using the same classes. This consistency makes working with streams of data easy. The main role of the StreamReader and Streamwriter classes is essentially to convert bytes of data into characters. Different character encoding types such as Unicode ASCII or UTF-8 use different byte sequences to represent their characters but no .
đang nạp các trang xem trước