2 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
FilePath.Text返回一個(gè)字符串,它是驅(qū)動(dòng)器上文件的位置
下面的代碼可以工作
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();
}

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
- 2 回答
- 0 關(guān)注
- 207 瀏覽
添加回答
舉報(bào)