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:
private void copyBinaryFile() { string FILE_NAME = "c:\\testImage.psd"; string FILE_NAME2 = "c:\\testImage2.psd"; // Create the reader for data. FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read); FileStream fs2 = new FileStream(FILE_NAME2, FileMode.CreateNew); BinaryReader r = new BinaryReader(fs); BinaryWriter w = new BinaryWriter(fs2); // Read data from File and Write to new file // This is the part I'm sure isn't right... System.Byte bt = r.ReadBytes(fs.Length); w.Write(bt); r.Close(); w.Close(); }
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




Reply With Quote