Groups | Blog | Home
all groups > dotnet xml > february 2004 >

dotnet xml : Embed XSD in Assembly


Eric Barr
2/6/2004 3:09:08 PM
I've found myself using XSD files for my datasets. I'm loading them up from
disk right now. I was hoping there was a way to embed the file in the
assembly, so I could have access to it without the disk read.

I know I could build a kludge of a string builder function ...I was looking
for a way to embed the entire file in my assembly.

Is this possible ?


Regards,
-eric

Chris J.T. Auld [MVP]
2/7/2004 9:59:06 AM
[quoted text, click to view]

Sure.
Either set the build action of the file in VS.Net to Embed or use the
/resource compiler flag.

Then to get the files at run time do something like
GetExecutingAssembly().GetManifestResourceStream("foo.xsd")

This will return a stream object containing the data- if you need a more
detailed example yell... I gotta get of the net now and go for my bike ride!

Cheers
Chris

P.S. Using GetExecutingAssembly assumes that the resource is compiled into
the assembly from which you are accessing it... there are other methods...
have a hunt for them
-------------------------------------------
Kognition Consulting Limited - Thought Meets Technology
Chris J.T. Auld - Managing Director
Microsoft MVP (Windows Mobile Devices)
Phone: +64 3 453 0064
Mobile: +64 21 500 239
Email: chris@kognition.co.nz

Eric Barr
2/10/2004 10:37:44 AM
Chris,

Thanks for the info, thats exactly what i what i wanted.


-eric

[quoted text, click to view]

AddThis Social Bookmark Button