从流而不是文件加载配置文件 [英] Load configuration file from stream instead of file

查看:27
本文介绍了从流而不是文件加载配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 OpenMappedExeConfiguration 和 ExeConfigurationFileMap 来加载配置文件.它们的重载表明它们只适用于文件名.有没有办法从流中加载配置文件?

I use OpenMappedExeConfiguration with ExeConfigurationFileMap to load configuration files. Their overloads suggest that they only work with filenames. Is there a way to load a configuration file from a stream?

背景:我想加载作为嵌入式资源存储的配置文件.没有文件表示!

Background: I want to load configuration files that are stored as embedded resources. There is no file representation!

推荐答案

没有 问题是这个类本身不读取配置.Configuration 类最终会使用文件路径本身来加载配置,而这个类实际上想要一个物理路径.

No. The problem is that this class itself do not read the configuration. The file path itself is eventually used by the Configuration class to load the configuration, and this class actually wants a physical path.

我认为唯一的解决方案是将文件存储到临时路径并从那里读取.

I think the only solution is to store the file to a temporary path and read it from there.

这篇关于从流而不是文件加载配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆