我要寻找从应用程序包打开.csv文件做一些单元测试。因此,我更喜欢一些模拟 File.ReadAllText(字符串路径)
这是不是 X.ReadAllText(URI URI)
。我还没有尚未能发现这一点。
I am looking to open a .csv file from the application pack to do some unit testing. So what I would really love is some analog to File.ReadAllText(string path)
which is instead X.ReadAllText(Uri uri)
. I haven't as yet been able to find this.
有谁知道是否有可能阅读的文本/字节(不介意它)从包中的文件,而无需先编译此文件到磁盘?
Does anyone know if it is possible to read text / bytes (don't mind which) from a file in the pack without compiling this file to disk first?
呵呵,并顺便说一句, File.ReadAllText(@包://应用:,,, / S preadSheetEngine /测试/ Example.csv)
没科技工作对我来说..和我已经做了 VAR应用=新的应用程序()
诱骗,以确保我有一个包开始了我的单元测试过程中。
Oh and btw, File.ReadAllText(@"pack://application:,,,/SpreadSheetEngine/Tests/Example.csv")
didn't work for me.. and I am already doing the var app = new Application()
trick to make sure I have a pack started up during my unit test.
刚刚获得来自Application.GetResourcePart()返回的流和使用的的StreamReader 使用ReadToEnd成员阅读所有的文字了。
Just get the stream from the Application.GetResourcePart() return value and use a StreamReader to read all the text out using the ReadToEnd member.