|
-
Mar 2nd, 2011, 06:29 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] GetManifestResourceStream & ResourceManager.GetStream
Hello
I have an application that has some files in the resources that i need to extract at run-time, but i can't find a way to do this...
Neither the Assembly.GetManifestResourceStream neither the My.Resources.ResourceManager.GetStream work.
I already tried in various forms to pass the string name of the resource:
- AssemblyName.Resource.Ext
- AssemblyName.Resource
- Resource.Ext
- Resource
And none of them work. I created a simple app to test this and added a little img.jpg:
The code:
vb.net Code:
Dim myAssm As Assembly = Assembly.GetExecutingAssembly
Dim myAssmName As String = myAssm.GetName.Name
Dim resor1 As String = String.Concat(myAssmName, ".img.jpg")
Dim resor2 As String = String.Concat(myAssmName, ".img")
Dim resor3 As String = "img.jpg"
Dim resor4 As String = "img"
Dim st As IO.Stream
st = myAssm.GetManifestResourceStream(resor1)
st = myAssm.GetManifestResourceStream(resor2)
st = myAssm.GetManifestResourceStream(resor3)
st = myAssm.GetManifestResourceStream(resor4)
st = My.Resources.ResourceManager.GetStream(resor1)
st = My.Resources.ResourceManager.GetStream(resor2)
st = My.Resources.ResourceManager.GetStream(resor3)
st = My.Resources.ResourceManager.GetStream(resor4)
What I'm missing here?
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Mar 2nd, 2011, 06:40 PM
#2
Re: GetManifestResourceStream & ResourceManager.GetStream
How exactly did you add the resources in the first place? The simplest option is to NOT add them to the solution at all, but simply add them to the Resources page of the project properties. If you add an image file named "MyImage.jpg" then you would access the resource like so:
vb.net Code:
Dim myImage As Image = My.Resources.MyImage
Note that the property hase the same name as the file WITHOUT the extension.
-
Mar 2nd, 2011, 06:52 PM
#3
Thread Starter
Frenzied Member
Re: GetManifestResourceStream & ResourceManager.GetStream
Just used the resources tab and added new resource.
Yes i know that, but in this particular case i need the resources, and "extract" some of them to the hd...
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Mar 2nd, 2011, 07:16 PM
#4
Re: GetManifestResourceStream & ResourceManager.GetStream
 Originally Posted by mickey_pt
Just used the resources tab and added new resource.
Yes i know that, but in this particular case i need the resources, and "extract" some of them to the hd...
I showed you how to create an Image object. An Image object has a Save method.
-
Mar 2nd, 2011, 07:29 PM
#5
Thread Starter
Frenzied Member
Re: GetManifestResourceStream & ResourceManager.GetStream
The image file was only a sample, i have other file types, like i wrote in the beginning of the thread...
But forgetting the file type, the GetManifestResourceStream and the ResourceManager.GetStream doesn't work why?
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Mar 2nd, 2011, 07:32 PM
#6
Re: GetManifestResourceStream & ResourceManager.GetStream
 Originally Posted by mickey_pt
The image file was only a sample, i have other file types, like i wrote in the beginning of the thread...
So? It doesn;t matter what type of data you have. All data can be saved to a file one way or another. Just write the appropriate code for each type of resource.
 Originally Posted by mickey_pt
But forgetting the file type, the GetManifestResourceStream and the ResourceManager.GetStream doesn't work why?
Because that is for resources that you have added via the Solution Explorer, not for those you access via My.Resources.
-
Mar 3rd, 2011, 05:21 AM
#7
Thread Starter
Frenzied Member
Re: GetManifestResourceStream & ResourceManager.GetStream
 Originally Posted by jmcilhinney
So? It doesn;t matter what type of data you have. All data can be saved to a file one way or another. Just write the appropriate code for each type of resource.Because that is for resources that you have added via the Solution Explorer, not for those you access via My.Resources.
So that was the problem, i assumed that the resources could be the ones in the resources of the application... 
Thanks once again.
Rate People That Helped You
Mark Thread Resolved When Resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|