I'm trying to read one image file and copy it to the same folder under another name.

Here's my c# Code..

VB Code:
  1. private void copyBinaryFile()
  2.         {
  3.             string FILE_NAME = "c:\\testImage.psd";
  4.             string FILE_NAME2 = "c:\\testImage2.psd";
  5.  
  6.             // Create the reader for data.
  7.             FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
  8.             FileStream fs2 = new FileStream(FILE_NAME2, FileMode.CreateNew);
  9.             BinaryReader r = new BinaryReader(fs);
  10.             BinaryWriter w = new BinaryWriter(fs2);    
  11.  
  12.             // Read data from File and Write to new file
  13.  
  14.                         // This is the part I'm sure isn't right...
  15.             System.Byte bt = r.ReadBytes(fs.Length);
  16.             w.Write(bt);
  17.  
  18.             r.Close();
  19.             w.Close();
  20.         }

I'm close. But I'm not sure how to loop through the binary reader and write the binary data to the new file? Eventually, I want to do this over a network and I don't know what the file types will be, so I have to read each file as binary and write it as binary to another folder.

How would I read the entire file and write the entire file as a new name?

Thanks