Take in variable, instead of direct file path?
I'm not sure how to ask this question actually...开发者_JAVA技巧
REF: http://qif.codeplex.com/
This API takes in the path of a file, can I have it take in a variable instead? binary of the file or string content of the file?
Not directly, but there is an overload of ImportFile
that takes a StreamReader
, so you can do something like that:
If you have the content as a byte array:
byte[] contentBytes = ... QifDom qifDom; using (Stream stream = new MemoryStream(contentBytes)) using (StreamReader reader = new StreamReader(stream)) { qifDom = QifDom.ImportFile(); }
If you have the content as a string:
string content = ... byte[] contentBytes = Encoding.UTF8.GetBytes(content); QifDom qifDom; using (Stream stream = new MemoryStream(contentBytes)) using (StreamReader reader = new StreamReader(stream)) { qifDom = QifDom.ImportFile(); }
(Bad API design, by the way... the parameter should have been TextReader
, not StreamReader
, so we could have used a StringReader
rather than converting the string to bytes)
Also, note that the example on the home page is incorrect (there is no QifDom.Import
property)
精彩评论