/ Published in: C#
Some static methods to help in working with byte arrays
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
namespace Kyrathasoft.ArraysAndCollections.WorkingWithByteArrays { using System; using System.IO; using System.Diagnostics; public static class clsWorkWithByteArrays { public static byte[] ReadByteArrayFromFile(string fileName) { byte[] buff = null; buff = br.ReadBytes((int)numBytes); return buff; } public static byte[] StringToByteArray(string str) { return encoding.GetBytes(str); } public static bool WroteByteArrayToFileSuccessfully(byte[] buff, string fileName) { bool response = false; try { bw.Write(buff); bw.Close(); response = true; } catch (Exception ex) { Debug.WriteLine(""); Debug.WriteLine("Error in WroteByteArrayToFileSuccessfully()"); Debug.WriteLine(ex.Message); Debug.WriteLine(""); } return response; } } }