Question : VB.NET 2008 Get resource file as IO.Stream

Hi,

I am developing a VB.NET 2008 application, consisting of a main EXE application and several resource DLLs.

I need two functions for the DLL:

1) one function to get a list of all files in the resources of the DLL.
2) one function to return 'by name' a resource file as a System.IO.Stream type.

NOTE: The files will not be "Embedded Resource" (this doubles the size of the DLL), so I think cannot use 'GetManifestResourceStream'.

I currently use:

Return New System.IO.MemoryStream(My.Resources.MyFileName)

but I want it to be called by name.


Thank you.

Answer : VB.NET 2008 Get resource file as IO.Stream

The values are byte arrays, so you would need something like this:

1:
2:
3:
4:
5:
6:
Imports System.IO

Public Shared Function GetResourceStream(ByVal resourceName As String) As MemoryStream
   Dim buffer As Byte() = CType(My.Resources.ResourceManager.GetObject(resourceName), Byte())
   Return New MemoryStream(buffer)
End Function
Random Solutions  
 
programming4us programming4us