Write data to file through FileStream via an array : FileStream : File Directory Stream C# Examples


C# Examples » File Directory Stream » FileStream »

 

Write data to file through FileStream via an array









    
using  System;
using  System.IO;

public  class  MainClass
{
    static  void  Main(string[]  args)
    {
        FileStream  MyFileStream1  =  new  FileStream(@"c:\Testing.txt",  FileMode.Create);

        int  NumberOfBytesToWrite  =  256;
        byte[]  MyWriteByteArray  =  new  Byte[NumberOfBytesToWrite];

        for  (int  i  =  0;  i  <  256;  i++)
        {
            MyWriteByteArray[i]  =  (byte)i;
            i++;
        }

        MyFileStream1.Write(MyWriteByteArray,  0,  NumberOfBytesToWrite);
        
        MyFileStream1.Close();        
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» FileStream