The MemoryStream creates a stream whose backing store is memory. Actually, it represents a pure, in-memory stream of data. Memory is much faster when compared to disk or network accesses. With MemoryStream, you can act upon the byte[] stored in memory rather than a file or other resource.
Use a byte[] because it is a fixed sized object making it easier for memory allocation and cleanup and holds relatively no overhead, especially since you don't need to use the functions of the MemoryStream.
This string is currently saved in the StreamWriters buffer. Flushing the stream will force the string whose backing store is memory MemoryStream. The StreamReader will read from the current position of the MemoryStream which is currently set at the end of the string earlier we just wrote to it. We have to set the position to 0 in order to read from the start. An invalid file type is specified in the fileType parameter. The following code example demonstrates using the SaveFile and LoadFile methods with streams.
It also demonstrates using the FileDialog. FileName , FileDialog. DefaultExt , SaveFileDialog. CreatePrompt , and SaveFileDialog. OverwritePrompt members. This version of the SaveFile method enables you to save the entire contents of the control to the data stream that is already opened.
The data stream can then save the information to a file. This version of the SaveFile method also enables you to specify a data format of the information that will be sent to the Stream object. WinPhone Device. Save stream ;. Save stream. SaveAsync stream ;. Save ;.
Add ". Close true ;. Korem Tom M Tom M 31 1 1 bronze badge. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Linked
0コメント