Click here to Skip to main content
15,887,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey all,

I'm trying to upload the file icon from a blob that is already uploaded. I'm using sasuri for the existing blob, (the one i want to upload the fileicon for).

Something like this:

//sasuri function
            var SASURI = GetUploadedFileIconSASURL(blobnamehere);

//retrieving fileicon for that blob
            var fileIcon = System.Drawing.Icon.ExtractAssociatedIcon(SASURI);

//and then somehow upload the icon as a new blob??

            CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobContainer();
            CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobiconnamehere);

            using (var stream = fileIcon.Openread())
            {
                blockBlob.UploadFromStream(stream);
            }


How can I upload a blockblob from a variabel like that? The stream is incorrect, does not contain a definition for OpenRead. (Im a newbie bare with me!)

Also, in theory, would this work? Will the icon be saved as a image?

Thanks in advance!!


Update 1:



var SASURI = GetUploadedFileIconSASURL(existingBlobNameHere);

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

CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobContainer();
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobiconnamehere);


Bitmap bmpIcon = fileIcon.ToBitmap();

using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
bmpIcon.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
blockBlob.UploadFromStream(ms);
}

Its running but the file icon blob is null(?)
Posted
Updated 9-Jun-14 7:58am
v3

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