C# 实现文件合并

private static string combineFile(string combinePath, List files)
        {
            if (File.Exists(combinePath + "\\temp")) {
                File.Delete(combinePath + "\\temp");
            }
            FileStream AddStream = new FileStream(combinePath + "\\temp", FileMode.OpenOrCreate);
            BinaryWriter AddWriter = new BinaryWriter(AddStream);
            string path;
            foreach (var item in files)
            {
                path = Path.Combine(@item.savepath, item.path);
                FileStream TempStream = new FileStream(path + "\\" + item.name, FileMode.Open);
                BinaryReader TempReader = new BinaryReader(TempStream);
                AddWriter.Write(TempReader.ReadBytes((int)TempStream.Length));
                TempReader.Close();
                TempStream.Close();
            }
            AddWriter.Close();
            AddStream.Close();
            return "temp";
        }

你可能感兴趣的:(C# 实现文件合并)