[問題] 文字檔使用split儲存於陣列中
目前我的程式碼如下:
ArrayList V = new ArrayList();
FileInfo txt = new FileInfo("C:\\Users\\BWF\\Desktop\\box.obj");//開啟box.obj
StreamReader read = txt.OpenText();
string line;
string[] CUT = new string[] { " " };//切割點
string[] words = new string[] { "" };
while(read.Peek() != -1)
{
line = read.ReadLine();
if (line.StartsWith("v "))
{
words = line.Split(CUT,StringSplitOptions.RemoveEmptyEntries);
}
}
for (int h = 0; h < words.Length; h++)//印出所有數值
{
Console.WriteLine(words[h]);
}
read.Close();
Console.ReadLine();
遇到的問題是,每行切割出來的值依照先後次序存放在陣列中,但每次數值都會被覆蓋,
不會依序存放。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.134.32.71
推
12/06 16:46, , 1F
12/06 16:46, 1F
→
12/06 17:01, , 2F
12/06 17:01, 2F
→
12/06 17:02, , 3F
12/06 17:02, 3F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章