Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class IOExtensions
- {
- public static void SaveToFile(this System.IO.Stream stream, string fileFullPath)
- {
- System.Diagnostics.Debug.Assert(string.IsNullOrEmpty(fileFullPath) == false);
- if (stream.Length == 0) return;
- using (System.IO.FileStream fileStream = System.IO.File.Create(fileFullPath))
- {
- const int bufferSize = 0x100;
- byte[] buffer = new byte[bufferSize];
- int bytesRead = 0;
- while ((bytesRead = stream.Read(buffer, 0, bufferSize)) > 0)
- {
- fileStream.Write(buffer, 0, bytesRead);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment