System.IO.Stream
You should never create a Stream Object directly
The Stream abstract class represents a sequence of bytes going to or coming from a storage medium.
The storage medium could be a file or a physical or virtual device.
You can have file streams, memory streams, network streams and tape streams.
The basic operations for a stream are read, write and seek.
Before you can do anything with the stream you have to attach it to a reader or writer.
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("")
Classes derived from Stream
System.IO.FileStream
System.IO.MemoryStream
System.IO.PipeStream
System.IO.BufferedStream
System.IO.UnmanagedMemoryStream
System.IO.Compression.DeflateStream
System.IO.Compression.GZipStream
System.Printing.PrintQueueStream
System.Data.SqlTypes.SqlFileStream
System.Net.Security.AuthenticatedStream
System.Net.Sockets.NetworkStream
System.Security.Cryptography.CryptoStream
Common Stream Properties
Length - Returns the total size of the stream. You can change the length using SetLength
Position - determines the current position in the stream. You can change the position using Seek.
Read - Reads a number of bytes from the specified position into a Byte array. The ReadByte method reads and returns a single byte.
Write - Writes a number of bytes from an array into the stream. The WriteByte can write a single byte.
Close - Closes the stream
Flush - Empties the buferred stream and ensures all the contents are written
BeginRead - start an asynchronous operation on the stream
BeginWrite - start an asynchronous operation on the stream
EndRead - To find out how many bytes were actually written
FileStream Class
This is one of the classes derived from the Stream class.
Data is not written to a file when you write to the FileStream.
You can check which operations are allowed by using the CanRead, CanWrite and CanSeek properties.
Dim objFileStream As System.IO.FileStream
objFileStream = System.IO.FileStream("C:\Temp\textfile.txt",
System.IO.FileMode.Open,
System.IO.FileAccess.Read,
System.IO.FileShare.Read)
If objFileStream.CanRead = True Then
End If
System.IO.FileMode.Append | Create | CreateNew | Open | OpenOrCreate | Truncate
System.IO.FileAccess.Read | Write | ReadWrite
System.IO.FileShare.None | ReadWrite | Read | Write | Inheritable
File streams are buffered
Handle - Returns the operating system file handle
Lock - Lock a portion of the file
UnLock - Unlock a portion of the file
SetLength - Trims or extends the underlying file.
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext