开发者

FileStream seems to find an unexisting file

I have this code:

public static string GetUserEmail()
{
    string path = Application.StartupPath + "\\mail.txt";
    MessageBox.Show(path)开发者_StackOverflow;
   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;
}

I checked the ApplicationPath with the MessageBox.Show(); as you can see, go there and delete the file, re-launch the app, and it still reads the previous line . I uninstall the app re-install and still seems to find the file and read the same line I have entered in the very first installation. I searched windows, the whole C drive, there is no mail.txt and it still finds the mail.txt and reads the line (a email address, used to identify the user)

What can it be? aliens?


Firstly, which code route does the program take? The one where the file is created, or the one where the existing file is read?

Try placing a breakpoint just before the existance of the file is checked and then go and check at that point if the file exists or not.


Do you have any code elsewhere that creates and writes the file, as part of the application startup?

Otherwise, its definitely aliens.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜