Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static bool ByteArrayToFile(string fileName, byte[] byteArray, int offset)
- {
- try
- {
- if (offset == 0)
- {
- using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
- {
- fs.Write(byteArray, 0, byteArray.Length);
- return true;
- }
- }
- else
- {
- using (var fs = new FileStream(fileName, FileMode.Append, FileAccess.Write))
- {
- Console.WriteLine(offset + " " + byteArray.Length);
- fs.Write(byteArray, offset, byteArray.Length);
- return true;
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Exception caught in process: {0}", ex);
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment