public static FileSerializer FromString(string str) { try { var stringBytes = str.Split(','); var bytes = new byte[stringBytes.Length]; for (var i = 0; i < stringBytes.Length; i++) { bytes[i] = Convert.ToByte(stringBytes[i]); } var fileSerializer = new FileSerializer { Bytes = bytes }; return(fileSerializer); } catch (Exception e) { var errorMessage = "An error occured while generating the file serializer. " + e.Message; throw new Exception(errorMessage); } }
public static FileSerializer FromFile(string filePath) { var fileSerializer = new FileSerializer { Bytes = GenerateBytes(filePath) }; return(fileSerializer); }