배열의 내용을 텍스트 파일에 쓰려고합니다. 배열에 텍스트 상자가 할당 된 파일을 만들었습니다 (올바르게 입력했는지는 확실하지 않음). 이제 배열의 내용을 텍스트 파일에 쓰려고합니다. streamwriter 부분은 내가 바닥에 붙어있는 곳입니다. 신텍스가 확실하지 않습니다.배열의 내용을 텍스트 파일에 쓰는 방법은 무엇입니까? C#
if ((!File.Exists("scores.txt"))) //Checking if scores.txt exists or not
{
FileStream fs = File.Create("scores.txt"); //Creates Scores.txt
fs.Close(); //Closes file stream
}
List<double> scoreArray = new List<double>();
TextBox[] textBoxes = { week1Box, week2Box, week3Box, week4Box, week5Box, week6Box, week7Box, week8Box, week9Box, week10Box, week11Box, week12Box, week13Box };
for (int i = 0; i < textBoxes.Length; i++)
{
scoreArray.Add(Convert.ToDouble(textBoxes[i].Text));
}
StreamWriter sw = new StreamWriter("scores.txt", true);
+1 : 아주 좋은 LINQ 솔루션! –