TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Loading Embedded Resources/Files

C#(C Sharp)

 
 
 
Thread Tools Display Modes
Old 09-10-2007, 08:24 PM   #1
Rasheed
Guest
 
Posts: n/a
Loading Embedded Resources/Files

Hi ,

Requirement is, I have to load my Xslt file into Exe/DLL.

I have created one .Xslt file and C# code for the same to produce
on .Xml file, like this:

System.Xml.XPath.XPathDocument Xmlpath = new
System.Xml.XPath.XPathDocument(filename);
XslTransform xsl = new XslTransform();
Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
("SolutionNameSpaceName.FormatConvertion.xslt") ;
System.Xml.XmlReader xmlReader = new System.Xml.XmlTextReader(xmlStrea
m );
xsl.Load(xmlReader);
XmlTextWriter textWriter = new XmlTextWriter(OutputPath +
"OutputFile.xml ", UTF8Encoding .Defaul t);
xsl.Transform(Xmlpath, list, textWriter);


My problem is with this statement:
Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
("SolutionNameSpaceName.FormatConvertion.xslt") ;

I have given my Application nameSpace "." Xslt filename but it returns
null into xmlStream.

For more informaton: I have read some information regarding
http://www.aisto.com/roeder/dotnet/ assembly Reflector, but still I
am unable to do this.

By using Reflector I am unable to see the Xslt file information after
loading the my solution DLL.

thanks in advance,
regards
Rs

 
Old 12-10-2007, 04:04 AM   #2
harborsparrow
Guest
 
Posts: n/a
Re: Loading Embedded Resources/Files

Something like this code should work, where xsltURL is a filepath like
"c:/rss.xsl":

public static string runTransform(string sourceURL, string
xsltURL)
{
//source
XmlTextReader reader = new XmlTextReader(sourceURL);
XmlDataDocument document = new XmlDataDocument();
document.Load(reader);

//target
StringWriter stw = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stw);
xmlTextWriter.Formatting = Formatting.Indented;

//transformation
XslCompiledTransform xslt1 = new XslCompiledTransform();
xslt1.Load(xsltURL);

// execute the transform and output the results to a file.
xslt1.Transform(sourceURL, xmlTextWriter);

//return HTML file
return stw.GetStringBuilder().ToString();
}


On Oct 9, 3:31 pm, Rasheed <sk.rasheedfar...***********> wrote:
> Hi ,
>
> Requirement is, I have to load my Xslt file into Exe/DLL.
>
> I have created one .Xslt file and C# code for the same to produce
> on .Xml file, like this:
>
> System.Xml.XPath.XPathDocument Xmlpath = new
> System.Xml.XPath.XPathDocument(filename);
> XslTransform xsl = new XslTransform();
> Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
> ("SolutionNameSpaceName.FormatConvertion.xslt") ;
> System.Xml.XmlReader xmlReader = new System.Xml.XmlTextReader(xmlStrea
> m );
> xsl.Load(xmlReader);
> XmlTextWriter textWriter = new XmlTextWriter(OutputPath +
> "OutputFile.xml ", UTF8Encoding .Defaul t);
> xsl.Transform(Xmlpath, list, textWriter);
>
> My problem is with this statement:
> Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
> ("SolutionNameSpaceName.FormatConvertion.xslt") ;
>
> I have given my Application nameSpace "." Xslt filename but it returns
> null into xmlStream.
>
> For more informaton: I have read some information regardinghttp://www.aisto.com/roeder/dotnet/ assembly Reflector, but still I
> am unable to do this.
>
> By using Reflector I am unable to see the Xslt file information after
> loading the my solution DLL.
>
> thanks in advance,
> regards
> R s



 
Old 17-10-2007, 08:22 PM   #3
Mark Dykun
Guest
 
Posts: n/a
Re: Loading Embedded Resources/Files

Rasheed,

Is it possible that you did not make the file an embedded resource. I am
guessing that this is the reason that you could not see the xslt file in the
assembly manifest.

Mark Dykun
VP Mobile and Integration Services, Castle CRM


"Rasheed" <sk.rasheedfarhan***********> wrote in message
news:1191958304.258797.208940@k79g2000hse.googlegr oups.com...
> Hi ,
>
> Requirement is, I have to load my Xslt file into Exe/DLL.
>
> I have created one .Xslt file and C# code for the same to produce
> on .Xml file, like this:
>
> System.Xml.XPath.XPathDocument Xmlpath = new
> System.Xml.XPath.XPathDocument(filename);
> XslTransform xsl = new XslTransform();
> Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
> ("SolutionNameSpaceName.FormatConvertion.xslt") ;
> System.Xml.XmlReader xmlReader = new System.Xml.XmlTextReader(xmlStrea
> m );
> xsl.Load(xmlReader);
> XmlTextWriter textWriter = new XmlTextWriter(OutputPath +
> "OutputFile.xml ", UTF8Encoding .Defaul t);
> xsl.Transform(Xmlpath, list, textWriter);
>
>
> My problem is with this statement:
> Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream
> ("SolutionNameSpaceName.FormatConvertion.xslt") ;
>
> I have given my Application nameSpace "." Xslt filename but it returns
> null into xmlStream.
>
> For more informaton: I have read some information regarding
> http://www.aisto.com/roeder/dotnet/ assembly Reflector, but still I
> am unable to do this.
>
> By using Reflector I am unable to see the Xslt file information after
> loading the my solution DLL.
>
> thanks in advance,
> regards
> Rs
>



 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot save any office files to network resources Rod Ahlbrandt Microsoft Office 8 16-12-2008 09:11 AM
loading files from a jump drive becky Windows Vista All 0 22-09-2007 01:08 PM
'embedded resources' and Dispose error..? Fred* C#(C Sharp) 8 09-09-2007 10:01 PM
can't open embedded files - I am using office 2003 Nick Microsoft Office 2 06-09-2007 06:59 AM
batching prior to XP Embedded loading boka Windows XP 0 16-08-2007 08:01 AM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 02:01 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional