I am trying to convert a part of a .txt file to TIFF image, as
public static void ReadTextFileLineByLine(string fileName)//fileName- "c:\\test.txt"
{
int counter = 0;
string line;
List<string> linelist = new List<string>();
System.IO.StreamReader file = new System.IO.StreamReader(strFileName);
while ((line = file.ReadLine()) != null && counter!=19)
{
linelist.Add(line);
counter++;
}
file.Close();
ConvertlistToByteArrayToTiff(linelist);
}
public static void ConvertlistToByteArrayToTiff(List<string> list)
{
byte[] dataAsBytes = list
.SelectMany(s => System.Text.Encoding.ASCII.GetBytes(s))
.ToArray();
MemoryStream ms = new MemoryStream(dataAsBytes);
Image returnImage = Image.FromStream(ms);
returnImage.Save("c:\\133.tiff", System.Drawing.Imaging.ImageFormat.Tiff);
}
I am getting error at Image.FromStream(ms);
:
Parameter is not valid.
Is my approach correct or I need to do it in different way?