views:

104

answers:

3

Hello Everyone,

I'm trying to integrate several components to build a custom reporting solution. One of these components is a template-based report generator. It reads a template consisting on a RTF file with placeholders and perform the substitution. This works great, and generates an RTF report.

Although it can generate the results as a stream instead of a physical RTF file, it has a property meant to specify the full name for the template (input) file. This is Ok on desktop applications but when talking about a WCF Service I would like to avoid the need to have a physical file in the HD.

All the templates are stored inside a database. The application reads it from there as a stream and then saves it to the HD as an RTF file. I'd like to know if it would be possible in c# to 'cheat' the report generator in such a way that I could specify a string consisting on a kind of 'virtual' or 'fictitious' path and then the componet would open the template from a memory stream as it was a real physical path on disc.

Any help will be appreciated.

Thanks in advance,

Gonzalo

+1  A: 

In C# 4 you can use memory mapped files: http://weblogs.asp.net/gunnarpeipman/archive/2009/06/21/net-framework-4-0-using-memory-mapped-files.aspx

Manu
MMF allows to access file through memory interface. He needs the reverse: access memory through the file interface.
atzz
Ok Manu, that's a good clue, but I'm using c# 3.5 right now. If I change to C# 4 in the future I'll consider this alternative.
+2  A: 

Depending on how the reporting solution works, you may be able to use a named pipe. See this MSDN page for more information, but the basic gist is that you would call CreateNamedPipe and specify the name you want to use (in the format listed on that MSDN page), then pass that name as the file name to your reporting solution.

Adam Robinson
Ok Adam, Thanks a lot. I wil perform some research about NamedPipes.Best wishes,Gonzalo
A: 

If the RTF library supports loading RTF files from the internet using WebRequest, you could call WebRequest.RegisterPrefix to make it call your own WebRequest class for specific Uris. If it only uses WebRequest for paths that begin with http, you could register the prefix http://MyNonExistantDomain.internal/.

SLaks
Hello SLaks,Unfortunatelly, it doesn't support web requests.Best regards,Gonzalo