ファイルのマージ

1442 ワード

  private List<string> files = new List<string>();//        
        public List<string> Files
        {
            get { return files; }
        }
        public void Combine(string fullName)
        {
            files.Add(@"C:\Documents and Settings\Administrator\  \Test\0.dat");
            files.Add(@"C:\Documents and Settings\Administrator\  \Test\1.dat");
            files.Add(@"C:\Documents and Settings\Administrator\  \Test\2.dat");
            MessageBox.Show(""+files.Count);
            byte[] buffer = new byte[1024 * 100];
            using (FileStream outStream = new FileStream(fullName, FileMode.Create))
            {
                int readedLen = 0;
                FileStream srcStream = null;
                for (int i = 0; i < files.Count; i++)
                {
                    srcStream = new FileStream(files[i], FileMode.Open);
                    while ((readedLen = srcStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        outStream.Write(buffer, 0, readedLen);
                    }
                    srcStream.Close();
                }
                MessageBox.Show("    !");
            }
            
        }