I am having trouble loading Tiff files in C# application. When tiff file is uploaded into application, it gets hanged up. This was happening because that tiff file is corrupt.
Please recommended a solution to identify this corrupt tiff files, so that application does not crash or hangs up when uploaded.
Below is the code snippet where when the file is opened in bmp object, the application hangs at that line of code.
public void ReadTiff(byte[] fileData)
{
try
{
using (var ms = new MemoryStream(fileData))
{
using (var bmp = new Bitmap(ms))
{
// Some code
}
}
}
catch (Exception ex)
{
throw ex;
}
}
I have tried following with the file:
- Tried opening in paint, it couldn't open.
- Also tried opening in Windows viewer, it couldn't open.
- Tried opening in multiple online image viewers, still it couldn't open.