在我的一个WebPages上,我放置了FileUpload1项目,我想在其中存储CSV文件然后对其进行分析。但是我无法阅读它,抛出异常。似乎文件路径发生了变化(我在桌面上有文件存储,而它显示在C:\ Program Files(x86)\ IIS Express中搜索文件)。
protected void Button2_Click(object sender, EventArgs
{
Response.Write("Jestem w petli file.hasfile");
if (FileUpload1.PostedFile != null)
{
string filePath = FileUpload1.PostedFile.FileName;
StreamReader reader = new StreamReader(filePath);
string[] readLines = new string[7];
int dayOfWeek = 0;
while (dayOfWeek < 7)
{
do
{
string textLine = reader.ReadToEnd();
readLines[dayOfWeek] = textLine;
}
while (reader.Peek() != -1);
dayOfWeek++;
}
for(int i = 0; i < 7; i++)
{
generateData(readLines[i], i);
}
reader.Close();
}
for(int i = 0; i < 7; i++)
{
TableRow tblRow = new TableRow();
Table1.Rows.Add(tblRow);
for (int j = 0; j < 2; j++)
{
TableCell tCell = new TableCell();
tCell.Text = positionsInWtr[i, j];
tblRow.Cells.Add(tCell);
}
}
}
你能告诉我我做错了吗?
提前致谢, KOKOS