title: Could my code cause a crash when creating a new file and directory under Windows 7?
body: <p>I have had some problems earlier which caused my program to crash in all Windows OS because I did not create a new file/directory for my file. Then I have assured that I have created file/folder before initializing ect. Now my program works in Windows XP but it doesn't work in Windows 7. By saying that it works I mean that it creates a file/folder needed for my program. By not working I mean that the file/folder isn't created in windows 7.</p>
  
  <p>Could this code be the cause of the crash under Windows 7? If so, how could I fix it?</p>
  
  <pre><code>    private static string dir = Environment.GetFolderPath
          (Environment.SpecialFolder.ProgramFiles) + @"\folder\";
      private static string file = dir + @"\Settings.txt";
      private string text;
  
      public void CheckFileStatus()
      {
          if (!Directory.Exists(dir))
          {
              DirectoryInfo directory = Directory.CreateDirectory(dir);
          }
          if (!File.Exists(file))
          {
              using (FileStream fileStream = File.Create(file))
              {
              }
          }
      }
  </code></pre>