デスクトップ上に作成されたtxtファイルを保存するにはどうすればよいですか?C#デスクトップ上にtxtファイルを保存する
これはコードです:
void CreaTxtBtnClick(object sender, EventArgs e){
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
filePath = filePath + @"\Error Log\";
TextWriter sw = new StreamWriter(@"Gara.txt");
int rowcount = dataGridView1.Rows.Count;
for(int i = 0; i < rowcount - 1; i++){
sw.WriteLine(
dataGridView1.Rows[i].Cells[0].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[1].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[2].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[3].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[4].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[5].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[6].Value.ToString() + '\t' +
dataGridView1.Rows[i].Cells[7].Value.ToString() + '\t'
);
}
sw.Close();
MessageBox.Show("File txt creato correttamente");
}
私は、これらの命令
Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
filePath = filePath + @"\Error Log\";
TextWriter sw = new StreamWriter(@"Gara.txt");
と私は、デスクトップ上のファイルを保存することができますが、TXTは間違ったパスに正しく作成されていることを考えました。 どうすれば修正できますか?
どこでそれを保存しましたか? – active92
プログラムのフォルダ – Matteo