StreamReader的和便携类库 [英] StreamReader and Portable Class Library
问题描述
我写使用便携式类库一个CONFIGMANAGER类。 PCL支持的StreamReader
和的StreamWriter
我想使用的类,但PCL版本这些类不支持传递在施工期间的字符串。 PCL也并不支持 reader.Close()
和 writer.Close()
。最后它不支持的FileStream
类。
所以我在寻找一个答案的任何一个以下几个问题:
- 我怎样才能获得
的StreamReader
和的StreamWriter
在PCL工作
类? - 如何创建一个新的
流
使用PCL? - 还有什么其他alternitives我要加载和保存在PCL文件?
使用的Dispose()
而不是关闭()
(或只是包装一切using语句)。我们已经隐藏/删除关闭()
在Windows Store应用程序和新的PCLS,因为它做同样的事情,人们会感到困惑调用哪一个。
考虑使用 PCL存储的跨平台文件系统的访问。
下面是您可能希望参考有关如何在PCLS接近特定平台功能的一些博客文章:
I am writing a ConfigManager class using Portable Class Libraries. PCL supports StreamReader
and StreamWriter
classes that I want to use, but the PCL version of those classes do not support passing in a string during construction. PCL also does not support the reader.Close()
and writer.Close()
. Lastly it doesn't support the FileStream
class.
So I am looking for an answer to any one of the following questions:
- How can I get the
StreamReader
andStreamWriter
classes working in a PCL? - How can I create a new
stream
using PCL? - What other alternitives do I have to load and save files in a PCL?
Use Dispose()
instead of Close()
(or just wrap everything in a using statement). We've hidden/removed Close()
in Windows Store apps and newer PCLs, because it does the same thing and people would be confused about which one to call.
Consider using PCL Storage for cross platform file system access.
Here are some blog posts you may want to refer to for how to approach platform-specific functionality in PCLs:
- How to Make Portable Class Libraries Work for You
- Portable Class Library Enlightenment / Adaptation
- Using Target-Specific Code in a Portable Library
这篇关于StreamReader的和便携类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!