LEADTOOLS Support
Imaging
Imaging SDK Examples
How To: Enable txt file support when loading from MemoryStream
#1
Posted
:
Thursday, March 19, 2020 3:33:03 PM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 14
When initially trying to load in a Text File from memory stream as a Raster Image, the default options for RasterCodecs disable the loading of the text file.
Code:
MemoryStream ms = new MemoryStream(File.ReadAllBytes(@"C:/temp/test.txt"));
RasterCodecs rasterCodecs = new RasterCodecs();
//Here we set this option to true, so that the Codecs is able to load in the txt file as a RasterImage from the memory stream
rasterCodecs.Options.Txt.Load.Enabled = true;
try
{
RasterImage image = rasterCodecs.Load(ms, 1);
Console.WriteLine("loaded");
Console.ReadLine();
}
catch (Exception ex) {
Console.WriteLine("Exception: " + ex.Message);
Console.WriteLine("Inner Exception " + ex.InnerException.Message);
}
By setting rasterCodecs.Options.Txt.Load.Enabled = true, we are able to get around this default behavior.
Pawel Lyko
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK Examples
How To: Enable txt file support when loading from MemoryStream
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.