gpt4 book ai didi

c# - 在 C# 中为 Windows Mobile App 创建一个文本文件

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:57 24 4
gpt4 key购买 nike

我是 C# 的新手,目前正在开发一个 Windows 移动应用程序,我必须在其中创建一个按钮单击事件的文本文件,并且必须写入页面中存在的文本字段的值。任何人都可以帮助我吗为此,我为此使用了 Visual 2008。

private void btnSubmit_Click(object sender, EventArgs e)
{
string path = "C:\\Users\\Mytext.txt";

if (!File.Exists(path))
{
File.Create(path);
TextWriter tw = new StreamWriter(path);
tw.WriteLine("The very first line!");
tw.Close();
}
else if (File.Exists(path))
{
TextWriter tw = new StreamWriter(path);
tw.WriteLine("The next line!");
tw.Close();
}
}

最佳答案

用那个

private void btnSubmit_Click(object sender, EventArgs e)
{
string path = "\\My Documents\\Mytext.txt";

if (!File.Exists(path))
{
File.Create(path);
TextWriter tw = new StreamWriter(path);
tw.WriteLine("The very first line!");
tw.Close();
}
else if (File.Exists(path))
{
TextWriter tw = new StreamWriter(path);
tw.WriteLine("The next line!");
tw.Close();
}
}
  1. Windows Mobile 6.x 设备上没有驱动器盘符
  2. 没有\users目录

忘掉针对 Windows Phone 或 Windows Embedded 8 Handheld 的答案。

关于c# - 在 C# 中为 Windows Mobile App 创建一个文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35912238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com