我有这个代码:
public static string GetUserEmail()
{
string path = Application.StartupPath + "\\mail.txt";
MessageBox.Show(path);
string adres = String.Empty;
if (File.Exists(path))
{
using (StreamReader sr = new StreamReader(path))
{
adres = sr.ReadLine();
}
}
else
{
using (FileStream fs = File.Create(path))
{
using (StreamReader sr = new StreamReader(path))
{
adres = sr.ReadLine();
}
}
}
MessageBox.Show(adres);
return adres;
}
我用 MessageBox.Show(); 检查了 ApplicationPath 如您所见,去那里删除文件,重新启动应用程序,它仍然会读取上一行。我卸载应用程序重新安装,似乎仍然找到文件并阅读我在第一次安装时输入的同一行。我搜索了windows,整个C盘,没有mail.txt,它仍然找到mail.txt并读取该行(电子邮件地址,用于识别用户)
会是什么?外星人?