// GET api/fileassembly public void Post(AssembleRequest item) { string mappedBlockPath = HttpContext.Current.Server.MapPath("~/" + blockpath); string mappedFilePath = HttpContext.Current.Server.MapPath("~/" + imagepath); string destinationFile = mappedFilePath + item.filename; List<string> sourcefiles = new List<string>(); //build up the blockstrings foreach(string block in item.blocks) { sourcefiles.Add(mappedBlockPath + block); } using (Stream destStream = File.OpenWrite(destinationFile)) { foreach (string srcFileName in sourcefiles) { using (Stream srcStream = File.OpenRead(srcFileName)) { srcStream.CopyTo(destStream); } } } //tidy up the old blocks foreach (string srcFileName in sourcefiles) { File.Delete(srcFileName); } }
// GET api/fileassembly public void Post(AssembleRequest item) { string mappedBlockPath = HttpContext.Current.Server.MapPath("~/" + blockpath); string mappedFilePath = HttpContext.Current.Server.MapPath("~/" + imagepath); string destinationFile = mappedFilePath + item.filename; List <string> sourcefiles = new List <string>(); //build up the blockstrings foreach (string block in item.blocks) { sourcefiles.Add(mappedBlockPath + block); } using (Stream destStream = File.OpenWrite(destinationFile)) { foreach (string srcFileName in sourcefiles) { using (Stream srcStream = File.OpenRead(srcFileName)) { srcStream.CopyTo(destStream); } } } //tidy up the old blocks foreach (string srcFileName in sourcefiles) { File.Delete(srcFileName); } }