将文件流文件保存在桌面上...而不是paerent文件夹。 [英] to save file of filestream on desktop...instead of the paerent folder.
问题描述
我有一个应用程序在f盘中。运行该应用程序时我将所有值存储在列表框中。我想在关闭应用程序后查看txt文件中的值,所以我使用了流编写器和文本编写器。 .f文件是在f盘中创建的,其中实际项目所在...在调试文件夹中......但是......我想保存在桌面上...所以我在这里给出了一段代码... plz chk ..
使用(FileStream fs3 = File.Create(values.txt))
{
使用(TextWriter tw = new StreamWriter(fs3))
{
int p;
string value;
for(p = 0; p< listBox2.Items.Count; p ++)
{
value = listBox2.Items [p] .ToString();
tw.Write(value);
tw.Write(\\\\ n);
< b r />
}
}
}
i have an application which is in f drive.while running that application i store all the values in a listbox.I wanted to view the values in a txt file after closing the application so i used stream writer and text writer...the file is created in f drive where the actual project resides...in debug folder...but..thing is i want to save on desk top..so i am giving the piece of code here...plz chk ..
using (FileStream fs3 = File.Create("values.txt"))
{
using (TextWriter tw = new StreamWriter(fs3))
{
int p;
string value;
for (p = 0; p < listBox2.Items.Count; p++)
{
value=listBox2.Items[p].ToString();
tw.Write(value);
tw.Write(\r\n);
}
}
}
推荐答案
阅读以下内容: http://stackoverflow.com/questions/634142/how-to-get-a-path-to-the-desktop-for-current-user-in-c [< a href =http://stackoverflow.com/questions/634142/how-to-get-a-path-to-the-desktop-for-current-user-in-ctarget =_ blanktitle =新窗口> ^ ]
Read the following : http://stackoverflow.com/questions/634142/how-to-get-a-path-to-the-desktop-for-current-user-in-c[^]
这篇关于将文件流文件保存在桌面上...而不是paerent文件夹。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!