請問一下..為何我list保存再for裡面看的到..再寫進去..去開該csv卻是空白檔??
private void button1_Click(object sender, EventArgs e)
{
DateTime CurrTime = DateTime.Now;
string year = CurrTime.Year.ToString();
string month = CurrTime.Date.Month.ToString();
string day = CurrTime.Date.Day.ToString();
string path = "D:\\CVP_System\\"+year+"_"+month+".csv";
ArrayList list = new ArrayList();
string[] s1 = new string[31];
string[] s2 = new string[3];
string[] s3 = new string[2];
int i = 0;
if (File.Exists(path))
{
sr = new StreamReader(path);
while (!sr.EndOfStream)
{
list.Add(sr.ReadLine());
}
sr.Close();
int x=list.Count;
s2 = list[x-1].ToString().Split('_');
s3=s2[1].Split(',');
//MessageBox.Show(s3[0].Equals(day).ToString());
if (s3[0] == day)
{
StreamWriter sw = new StreamWriter(path);
for(int z = 0; z < x; z++)
{
sw.WriteLine(list[z].ToString());
}
}
}
}
圖片
if (s3[0] == day)
{
StreamWriter sw = new StreamWriter(path);
for(int z = 0; z < x; z++)
{
sw.WriteLine(list[z].ToString());
}
}
加一列試試看
if (s3[0] == day)
{
StreamWriter sw = new StreamWriter(path);
for(int z = 0; z < x; z++)
{
sw.WriteLine(list[z].ToString());
}
sw.close();
}