【问题标题】:how to parse local CSV file wp7如何解析本地CSV文件wp7
【发布时间】:2013-03-09 12:52:59
【问题描述】:

我正在开发一个 wp7 应用程序,我需要读取 CSV 文件并存储到列表中

csv 文件为 20 行,名字、姓氏之间用 ,(逗号)分隔

我尝试使用http://kbcsv.codeplex.com/ 这个和http://www.codeproject.com/articles/25133/linq-to-csv-library 当我试图包含这些 dll 时得到“windows phone 项目将只适用于 windows phone 程序集”错误

如何在 windows phone 7 中解析 csv 文件

提前致谢

【问题讨论】:

标签: c# windows-phone-7 csv


【解决方案1】:

使用 IsolatedStorageFileStream 从保存的路径位置获取并打开文件。 然后用 StreamReader 对象读取。

    IsolatedStorageFileStream fileStream = storage.OpenFile(filePath, FileMode.Open, FileAccess.Read);
    using (StreamReader reader = new StreamReader(fileStream))
    {
      string line;
      while ((line = reader.ReadLine()) != null)
      {
        string[] temp1Arr = line.Split(',');

        //Manipulate your string values stored in array here 
      }
    }

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    相关资源
    最近更新 更多