Writing data : File Copy : File Directory Stream C# Examples


C# Examples » File Directory Stream » File Copy »

 

Writing data









    
using  System;
using  System.Collections.Generic;
using  System.Collections.Specialized;
using  System.IO;
using  System.IO.Compression;
using  System.Net;
using  System.Net.Mail;
using  System.Net.Sockets;
using  System.Runtime.InteropServices;
using  System.Text;
using  System.Threading;

public  class  MainClass
{
        public  static  void  Main()
        {
                using  (Stream  from  =  new  FileStream("c:\\test.txt",  FileMode.Open))
                using  (Stream  to  =  new  FileStream("c:\\test2.txt",  FileMode.OpenOrCreate))
                {
                        int  readCount;
                        byte[]  buffer  =  new  byte[1024];
                        while  ((readCount  =  from.Read(buffer,  0,  1024))  !=  0)
                        {
                                to.Write(buffer,  0,  readCount);
                        }
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» File Copy