I have a WinForms application that checks for a TXT file in the application directory. There will be only a single line (user's email) or none. the code is like this:
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;
}
This Seems to work except one really weird behaviour. When I uninstall the program, and re-install, it still finds the file and reads the previous e-mail. I checked the ApplicationDirectory there is no such file, searched Windows, whole C drive, there is noı mail.txt but it still finds and read the mail address that I have entered in the very first installation. Thanks in advance for any help.