如何指定磁盘上文件的物理路径,但访问内存位置?

发布于 2024-08-14 01:22:30 字数 388 浏览 3 评论 0原文

我正在尝试集成多个组件来构建自定义报告解决方案。这些组件之一是基于模板的报告生成器。它读取由带有占位符的 RTF 文件组成的模板并执行替换。这非常有效,并生成 RTF 报告。

尽管它可以将结果生成为流而不是物理 RTF 文件,但它有一个属性用于指定模板(输入)文件的全名。这在桌面应用程序上是可以的,但在谈论 WCF 服务时,我想避免在硬盘中需要有物理文件。

所有模板都存储在数据库中。应用程序从那里将其作为流读取,然后将其作为 RTF 文件保存到 HD。 我想知道在 C# 中是否有可能以这样的方式“欺骗”报告生成器:我可以指定一个由某种“虚拟”或“虚构”路径组成的字符串,然后组件将打开来自内存流的模板,因为它是光盘上的真实物理路径。

任何帮助将不胜感激。

提前致谢,

贡萨洛

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

送你一个梦 2024-08-21 01:22:30

根据报告解决方案的工作方式,您也许可以使用命名管道。有关详细信息,请参阅此 MSDN 页面,但基本要点是您将调用 CreateNamedPipe 并指定您要使用的名称(采用该 MSDN 页面上列出的格式),然后将该名称作为文件名传递到您的报告解决方案。

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.

貪欢 2024-08-21 01:22:30

如果 RTF 库支持使用 WebRequest 从 Internet 加载 RTF 文件,您可以调用 WebRequest.RegisterPrefix 使其针对特定 UriWebRequest 类>s。如果它仅对以 http 开头的路径使用 WebRequest,您可以注册前缀 http://MyNonExistantDomain.internal/

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/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文