【发布时间】:2012-06-20 22:17:51
【问题描述】:
我要做的是从名为“附件”的 Windows 应用程序文件夹中的 CSV 文件中读取数据。在 Web 应用程序中,您可以使用
获取文件夹的路径Server.MapPath(@"Attachments/sample.csv");
来自 Windows 应用程序的等效调用是什么?
下面是我的代码。
string[] str = File.ReadAllLines(@"Attachment/sample.csv");
// create new datatable
DataTable dt = new DataTable();
// get the column header means first line
string[] temp = str[0].Split(';');
// creates columns of gridview as per the header name
foreach (string t in temp)
{
dt.Columns.Add(t, typeof(string));
}
【问题讨论】: