2 回答
TA贡献1828条经验 获得超3个赞
FilePath.Text返回一个字符串,它是驱动器上文件的位置
下面的代码可以工作
using (StreamReader reader = new StreamReader(FilePath.Text))
{
// We read the file then we split it.
string lines = reader.ReadToEnd();
string[] splittedArray = lines.Split(',');
// We will check here if any of the strings is empty (or just whitespace).
foreach (string currentString in splittedArray)
{
if (currentString.Trim() != "")
{
// If the string is not empty then we add to our temporary list.
temp.Add(currentString);
}
}
// We have our splitted strings in temp List.
// If you need an array instead of List, you can use ToArray().
finalArray = temp.ToArray();
}
- 2 回答
- 0 关注
- 149 浏览
添加回答
举报