all groups > dotnet sdk > september 2004 >
You're in the

dotnet sdk

group:

How to read files from assembly


How to read files from assembly Yoges
9/22/2004 4:37:00 PM
dotnet sdk:
Hi,

I my .Net Class library project I have added the .xsl file. I need to get
the contents of the file by loading the Assembly Dll. Is there any way to
get the file contents.


Thanks and Regards,
Yogesh

Re: How to read files from assembly hashimi_sayed NO[at]SPAM hotmail.com
9/30/2004 5:06:17 AM
Yogesh,

You can load files from your dll. Here are the steps:

1) Add the file to your dll. Right click on the file in Visual Studio
and choose Properties. You need to set the "Build Action" property to
"Embedded Resource".
2) Compile the assembly; this will embed the file into your dll.
3) To load the assembly, you can do Assembly.Load(); This will give
you an Assembly reference. Note if you are loading the xsl file from
within the same assembly, you can use Assembly.GetExecutingAssembly().
4) Use the assembly reference to get a stream to the xsl file. You can
do this by calling the GetManifestResourceStream() method. Here is an
example:

Assembly.GetExecutingAssembly.GetManifestResourceStream("com.abc.file.xsl");

Note that you have to supply the fully qualified file name.

sayed

[quoted text, click to view]
AddThis Social Bookmark Button