prabhat khadka

prabhat khadka

  • NA
  • 14
  • 21.7k

copy multiple file

Nov 30 2007 7:21 AM
I have written a code that copies one file of a folder using byte[].Code is below:
private static void sendFile()
        {
            string folderpath = @"c:\screenshot\ram.jpeg";
          
            try
            {
               // DirectoryInfo di = new DirectoryInfo(folderpath);
               // FileInfo[] fi = di.GetFiles();
               // foreach(FileInfo Finfo in fi)
                {
                    FileStream fs;
                    fs = new FileStream(folderpath,FileMode.Open);
                    byte[] byteFile = new byte[fs.Length];
                    fs.Read(byteFile,0,byteFile.Length);
                    fs.Close();
                    getbyte(byteFile, "ram");

                }
           
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
       
        }
        private static void getbyte(byte[] mybte,string filename)
        {

            
            byte [] byteFile= mybte;
       
            //    LogManager.managelog("file name requested is" +line);
           
                FileStream fs;
               
                string saveTo=@"C:\copyPath";
                fs = new FileStream(saveTo + @"\" + filename,FileMode.Create);

                fs.Write(mybte, 0, byteFile.Length);
                fs.Close();   
                }
    }

How to copy the whole .jpeg  files from the screenshot  folder to copypath folder??
Thanx in advance.

Answers (2)