Sanju Singh

Sanju Singh

  • NA
  • 280
  • 44.3k

Fast copying of data to a file

Feb 27 2015 1:00 AM
hello,

        i wish to know if there is a way to copy data to a file faster then the following approach used below ? What i am doing is to write matrix/array data to a .cvs file. there are on an average 150,000 elements in the array/matrix with each element having three double data type members.The code is here: 


           var path = Path.Combine(myData, "KinectData-" + time + ".txt");

         
            // start writing the data to file
            for (int i = 0; i < maxLen; i++)
            {
                System.IO.File.AppendAllText(@path, Convert.ToString(p1[i].X) + " ," +                         Convert.ToString(p1[i].Y) + " ," + Convert.ToString(p1[i].Z) +                                                                                                 Environment.NewLine);

                System.IO.File.AppendAllText(@path, Convert.ToString(p2[i].X) + " ," +                 Convert.ToString(p2[i].Y) + " ," + Convert.ToString(p2[i].Z) +                                                                                                 Environment.NewLine);
           
             }

The time taken for this process is close to 3 min which i wish to minimize.any solution will be  of great value to me.

Thank you








Answers (5)