Text file as embedded resource

R

Ron Vecchi

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
 
E

Eric Cadwell

Look at Assembly.GetManifestResourceStream.

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

HTH;
Eric Cadwell
http://www.origincontrols.com
 
J

Jeffrey Tan[MSFT]

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/embeddedresources.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/default.asp?url=/library/en-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" <[email protected]>
| 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: <[email protected]>
| 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!tk2msftngp13.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
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top