0
目前,我想寫被輸入到ComboBox
(從Outlook加載項)到一個txt文件的URL網址,但我初學我真的不知道該怎麼去爲它。使用的TextWriter寫入從組合框
我沒有任何代碼段,可以幫助你,無論如何,所以我想我還是保持簡單,問你的,我可以在這個問題上使用的一般方法。 所有的幫助表示感謝,謝謝。
目前,我想寫被輸入到ComboBox
(從Outlook加載項)到一個txt文件的URL網址,但我初學我真的不知道該怎麼去爲它。使用的TextWriter寫入從組合框
我沒有任何代碼段,可以幫助你,無論如何,所以我想我還是保持簡單,問你的,我可以在這個問題上使用的一般方法。 所有的幫助表示感謝,謝謝。
試試這個:
添加組合項目的List
和使用File
List<string> lst = new List<string>();
foreach (var text in comboBox1.Items)
{
lst.Add((string)text);
}
File.WriteAllLines(@"c:\file.txt", lst.ToArray());
其寫入文件中使用TextWriter
using (TextWriter TW = new StreamWriter(@"c:\file.txt", true))
{
foreach (var text in comboBox1.Items)
{
TW.WriteLine();
}
}
這是你在找什麼?
string [email protected]"C:\Hello.txt";
TextWriter tsw = new StreamWriter(path,true);
//Writing selected item of combobox to the file.
tsw.WriteLine(comboBox1.Items[this.comboBox1.SelectedIndex].ToString());
//Close the file.
tsw.Close();