locked
Save embedded resource to file RRS feed

  • Question

  • Hello!

    I have a problem with VB 2010. In my project, I have 2 embedded resources that I want to save to disk. Both are of type System.Drawing.Icon (*.ico file).

    I tried searching all over Google, and found no threads that helped me out.

    Either I need to figure out:

    • How to convert a System.Drawing.Icon to a 1-dimensional array of Byte()
    • How to use a System.IO.Stream to save the icon using My.Resources.<resourcename>.Save(outputStream as System.IO.Stream)
    • Any other method that may work

    I would be very happy if I could find a solution to this.

    - bilde2910 :)

    Sunday, February 12, 2012 9:58 AM

Answers

  •         Dim ico = My.Resources.Icon1
            Using fs = IO.File.Create("C:\Test\IcoTest.Ico")
                ico.Save(fs)
            End Using


    Success
    Cor

    • Marked as answer by bilde2910 Sunday, February 12, 2012 11:26 AM
    Sunday, February 12, 2012 10:20 AM

All replies

  •         Dim ico = My.Resources.Icon1
            Using fs = IO.File.Create("C:\Test\IcoTest.Ico")
                ico.Save(fs)
            End Using


    Success
    Cor

    • Marked as answer by bilde2910 Sunday, February 12, 2012 11:26 AM
    Sunday, February 12, 2012 10:20 AM
  • Oh wow, I had no idea it was that simple.

    Well, it's a point in it, if you can't find anything on Google, then either:

    • It is incredibly hard to do
    • It is incredibly easy to do
    • Nobody has ever done it before

    As this time it was the 2nd case.

    Thanks for the help!

    Sunday, February 12, 2012 11:28 AM
  •         Dim ico = My.Resources.Icon1
            Using fs = IO.File.Create("C:\Test\IcoTest.Ico")
                ico.Save(fs)
            End Using

    Hi Cor,

    after one looong day without internet access... Did you know that ico.save does not save in .ico format? I thought so, too. See first answer here:

    http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/341eb43e-5928-4ff5-813d-f5ea52411773


    Armin

    Monday, February 13, 2012 12:13 PM