I get byte by a file and i want to build the same file from the byte array. I tried this but it isn't working Write bytes to file
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
string[] strings = { splitedPacket[3] };
byte[] bytesConverted = Array.ConvertAll(strings, Byte.Parse);
fs.Write(bytesConverted, 0, bytesConverted.Length);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caught in process: {0}", ex);
}
Exception thrown: 'System.FormatException' in mscorlib.dll
Exception caught in process: System.FormatException: The format of the input string is incorrect.
at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info)
at System.Byte.Parse(String s)
at System.Array.ConvertAll[TInput,TOutput](TInput[] array, Converter`2 converter)
at JeSaisPas.ConnectionUtils.<>c__DisplayClass5_0.<Server>b__0(Object s, DoWorkEventArgs args) in Util.cs:line 142