Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Once again I'm here with a question..

I want to extract the icon from a file that is stored in azure blob storage.

Action:

C#
public FileResult GetUploadedFileIcon(string blobname)
{
    string SASURI = GetUploadedFileIconSASURL(blobname);

    Icon stream = System.Drawing.Icon.ExtractAssociatedIcon(SASURI);
    Bitmap pngIcon = stream.ToBitmap();

    MemoryStream ms = new MemoryStream();
    pngIcon.Save(ms, ImageFormat.Png);

    ms.Position = 0;

    return new FileStreamResult(ms, "image/png");
}


View:

C#
<img src="@Url.Action("GetUploadedFileIcon", "Home", new { blobname = file.BlobName })" />


The problem:

It's telling me icon stream is null. Nothing is wrong with the SASURI. I tried removing it completely and go with public container but that did not help. I also tried getting the icon from a locally stored file, like this:

C#
Icon stream = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\WINDOWS\system32\notepad.exe");

And that worked..

The content type for all the blobs are correct, textfiles are text/plain etc.

Why am i getting null value on my icon when I try to extract the icon from a blob?

And as always i appreciate all the help I can get!!

Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900