By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,666 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,666 IT Pros & Developers. It's quick & easy.

Text file as embedded resource

P: n/a
I have a text file(.js) that holds a buch of java script code that is
rendered in some web controls all part of a larger webcontrol library.

The file is rather large. Would embedding this resouce in the application
be relevant in this situation. I know I can chage the build type to
embedded resource but really dont know what this does. Besides that it
embeds it in the assembly ;-). I'm pretty quick.

How can I read the text file once its embedded though. Like I metioned
there are a couple webcontrols that use this text file and render out some
of the contents.

Thanks,
Ron
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Hi Ron,

You can refer to Assembly.GetManifestResourceStream method, it will read
the resource into a stream.
Then you can use filestream to operate it as you like.

For details, please refer to:
http://www.codeproject.com/dotnet/em...asp?print=true
http://www.devx.com/dotnet/Article/10831/0/page/2

Also, you can use ResourceManager Class to retrieve embedded resources at
run time.
You can visit:
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskretrievingresourceswithresourcemanager.asp

If you still have anything unclear, please feel free to let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Ron Vecchi" <rv*****@xilehdvecchi.com>
| Subject: Text file as embedded resource
| Date: Mon, 20 Oct 2003 18:45:32 -0400
| Lines: 16
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <O4**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: pcp02828467pcs.roylok01.mi.comcast.net 68.85.156.233
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:192711
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have a text file(.js) that holds a buch of java script code that is
| rendered in some web controls all part of a larger webcontrol library.
|
| The file is rather large. Would embedding this resouce in the application
| be relevant in this situation. I know I can chage the build type to
| embedded resource but really dont know what this does. Besides that it
| embeds it in the assembly ;-). I'm pretty quick.
|
| How can I read the text file once its embedded though. Like I metioned
| there are a couple webcontrols that use this text file and render out some
| of the contents.
|
| Thanks,
| Ron
|
|
|

Nov 15 '05 #2

P: n/a
Look at Assembly.GetManifestResourceStream.

private Stream GetFileStream(string Path)
{
Assembly assembly = Assembly.GetExecutingAssembly();
return assembly.GetManifestResourceStream(Path);
}

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #3

P: n/a
Great this should get me going, Thanks
"Ron Vecchi" <rv*****@xilehdvecchi.com> wrote in message
news:O4**************@tk2msftngp13.phx.gbl...
I have a text file(.js) that holds a buch of java script code that is
rendered in some web controls all part of a larger webcontrol library.

The file is rather large. Would embedding this resouce in the application
be relevant in this situation. I know I can chage the build type to
embedded resource but really dont know what this does. Besides that it
embeds it in the assembly ;-). I'm pretty quick.

How can I read the text file once its embedded though. Like I metioned
there are a couple webcontrols that use this text file and render out some
of the contents.

Thanks,
Ron

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.