Unraveling the confusion about Embedded Resources

前端 未结 2 1640
既然无缘
既然无缘 2020-12-29 10:30

EDIT: Read answer number 1 from Tim Schmelter and then use this question for examples of how to embed resources and access them at runtime.

The subj

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 11:07

    Just an update for anyone who wants to use this code. The code actually writes one additional byte to the file due to zero-based declaration of the byte array.

    To get an exact copy of the original file change the code to:

    Using s As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(WindowsApplication1.test.exe)
        Dim bytes(s.Length-1) As Byte
        s.Read(bytes, 0, bytes.Length)
        File.WriteAllBytes(“C:\test.exe”, bytes)
    End Using
    

提交回复
热议问题