- Both GZip and DEFLATE compression systems allow compression for a maximum of 4GB data.
- GZipStream is useful for wider distribution scenario while DeflateStream is useful for relatively smaller size (because it does not include header information)
- Compression Streams would always wrap the FileStream with compressed data, whether during Compression or Decompression.
Showing posts with label FileStream. Show all posts
Showing posts with label FileStream. Show all posts
Thursday, June 11, 2009
Chapter 3-Lesson 3
Sunday, June 7, 2009
Chapter 2-Lesson 2
- Most operations with Streams involve the File class
- StreamReader and StreamWriter classes allow for sequential reading and writing of data.
- Static methods in the File class are almost identical to the FileInfo class.
- Simple Create( ) method (or Open, etc) would return a FileStream object where as CreateText( ) method (or OpenText, etc) would return a StreamReader/StreamWriter object.
- The Directory class provides static methods for routine directory operations.
- The FileAccess enum provides the possible rights assigned when accessing a file.
- Using FileAccess.Read would allow read-only access, whereas FileAccess.Write would allow append-only access.
- The FileMode enum determines whether file would be created or opened or deleted, etc.
- FileMode.Append can only be used with FileAccess.Write
- FileMode.Create overwrites any existing file while FileMode.CreateNew throws an exception if file exists.
- Similarly FileMode.Open would throw an exception if file does not exist but FileMode.OpenOrCreate wont.
- The Length property of the Stream class returns length of a stream in bytes.
- The SetLength property will Truncate (shrink) the contents of the stream if new length is lesser than the old one and vice versa.
- The StreamReader is intended to read the Stream as a string rather than as bytes.
- The StreamReader class is derived from the abstract TextReader class. StreamWriter derives from TextWriter abstract class.
- Similarly StringReader/StringWriter inherit from TextReader/TextWriter class. StringWriter uses a StringBuilder.
- For non-textual data there are BinaryReader/BinaryWriter classes.
- One use of MemoryStream is like we use datasets for database operations. You may continue to write on a MemoryStream and when you decide to make chages permanent you wirte a MemoryStream to a FileStream. This would lock the actual file for a short period of time reducing accessibility downtime.
Subscribe to:
Posts (Atom)