NetworkStream in C# Socket

The NetworkStream class implements the standard stream mechanism to read and write network data through an instance of the Socket class. The NetworkStream class allows network data to be read and written in the same manner as the System.IO.Stream class. This class supports simultaneous synchronous and asynchronous access to the network data. Random access is […]
Continue reading…

Enjoyed this post? Share it!

 
 

The FileStream object in c# .NET

The FileStream object provides access to the contents of a file, both for reading and writing purposes. It accesses file data at the byte level, and so is not always the best choice for accessing file data. A FileStream instance maintains a position byte index within a file so that you can navigate through the […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading Data from an Input Stream in C# .NET

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace StreamRead { class Program { static void Main(string[] args) { string line;   try { FileStream aFile = new FileStream("Log.txt", FileMode.Open); StreamReader sr = new StreamReader(aFile); line = sr.ReadLine(); // Read data in line by line. while (line != null) { Console.WriteLine(line); line […]
Continue reading…

Enjoyed this post? Share it!

 
 

Writing Data to an Output Stream in C# .NET

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace StreamWrite { class Program { static void Main(string[] args) { try { FileStream aFile = new FileStream("Logfile.txt", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(aFile);   bool truth = true; // Write data to file.   sw.WriteLine("It is now {0} and things are looking good.", […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading data from a Isolated Storage in C#

The IsolatedStorageFileStream class in c-sharp is used to deal with reading data from Assembly/Machine-User level store created by calling the GetMachineStoreForAssembly method on an instance object of the IsolatedStorageFile class. The IsolatedStorageFileStream class inherits from the FileStream and hence methods such as Read(), ReadByte(), Seek can be used to read data. IsolatedStorageFile mStore = IsolatedStorageFile.GetMachineStoreForAssembly(); […]
Continue reading…

Enjoyed this post? Share it!

 
 

Types of Isolated Storages in C#

There are two types of Isolated Storages supported by c-sharp to save data in a sandbox. The scope of the data residing in the Isolated Storages determine what kind of Isolated Storages must be used. Assembly/Machine : This data store can be created to store data specific to a calling assembly and the local machine. […]
Continue reading…

Enjoyed this post? Share it!

 
 

Isolated Storage in C#

The concept of Isolated Storage in c-sharp mirrors that of using a sandbox for running your application, without worrying about whether the application is running in partial, limited or full trust on the windows operating system. Isolated Storage prevents other programs such as malware from getting access to the data stored by the application. Isolated […]
Continue reading…

Enjoyed this post? Share it!

 
 

Decompress a data file using DeflateStream in C#

The DeflateStream reads data from one stream and writes to another stream. The DeflateStream does not write to another resource like a file or memory. DeflateStream writes to another stream and when doing so it decompresses the data. The general process for decompressing a data file using DeflateStream is Open an existing file Open/create output […]
Continue reading…

Enjoyed this post? Share it!

 
 

Decompress a data file using GZipStream in C#

The GZipStream reads data from one stream and writes to another stream. The GZipStream does not write to another resource like a file or memory. GZipStream writes to another stream and when doing so it decompresses the data. The general process for decompressing a data file using GZipStream is Open an existing file Open/create output […]
Continue reading…

Enjoyed this post? Share it!

 
 

Compress a data file using DeflateStream in C#

The DeflateStream method reads data from one stream and writes to another stream. The DeflateStream does not write to another resource like a file or memory. DeflateStream writes to another stream and when doing so it compressesses/decompresses the data. The general process for compressing a data file using Deflate is Open an existing file Open/create […]
Continue reading…

Enjoyed this post? Share it!

 
 

Compress a data file using GZipStream in C#

The GZipStream reads data from one stream and writes to another stream. The GZipStream does not write to another resource like a file or memory. GZipStream writes to another stream and when doing so it compressesses/decompresses the data. The general process for compressing a data file using GZipStream is Open an existing file Open/create output […]
Continue reading…

Enjoyed this post? Share it!

 
 

Deflate vs GZip in C#

The .NET Framework supports Deflate and GZip for stream compression and decompression. Stream compression can be used to save space and bandwidth. The maximum amount of compression by using Deflate and GZip is upto 4gb. Both Deflate and Gzip use the same underlying algorithm. GZip allows for extra headers to be included in the compressed […]
Continue reading…

Enjoyed this post? Share it!

 
 

How to read data from the XML file using FileStream and display it in a DataGrid?

The DataSet.ReadXml method reads XML schema and data into the DataSet using the specified file. The filename (including the path) from which to read is the parameter to the method. Its return value is the XmlReadMode used to read the data. The XmlReadMode used to read the data. 1 2 3 4 5 DataSet ds= […]
Continue reading…

Enjoyed this post? Share it!