0

我正在尝试从嵌入式资源中检索图像,并以其 RAW DATA 格式(即 -> 垃圾文本数据)显示它。

基本上,我尝试的一切都在碰壁。有人可以告诉我如何正确地做到这一点吗?

4

1 回答 1

0

您可以使用以下msdn 参考

System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(fileName)

这将为您提供一个 Stream,然后您可以使用code cite将其转换为几乎是原始数据的字节数组。

private Function GetStreamAsByteArray(ByVal stream As System.IO.Stream) As Byte()
Dim streamLength As Integer = Convert.ToInt32(stream.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
' Read the file into a byte array
stream.Read(fileData, 0, streamLength)
stream.Close()
Return fileData
End Function
于 2009-06-28T19:34:37.783 回答