title: StreamWriter doesn't create a text file
body: <p>I have writtten a code to Create &amp; write a file.But It doen't create a file.There's no any compilation error.My folder hierachy is DesktopModules -> SMSFunction->SMSText.I need to create a text file inside the SMSText folder,</p>
  
  <pre><code>public void WriteToFile(  string source, int dest, string messageIn, string operatorNew)
  {
      try{
  
      string directory = ResolveUrl("~/DesktopModules/SMSFunction/SMSText");
      //string directory = Server.MapPath("~/DesktopModules/SMSFunction/SMSText");
      string filename = String.Format("{0:yyyy-MM-dd}__{1}.txt", DateTime.Now);
      string path = Path.Combine(directory, filename);
  
      if (!File.Exists(filename))
      {
  
          using (StreamWriter str = File.CreateText(path))
          {
              str.WriteLine("msisdn: " + source);
              str.WriteLine("shortcode : " + dest);
              str.WriteLine("Message : " + messageIn);
              str.WriteLine("Operator :" + operatorNew);
              str.Flush();
  
          }
      }
      else if (File.Exists(filename))
      {
  
          using (var str = new StreamWriter(filename))
  
          {
              str.WriteLine("msisdn: " + source);
              str.WriteLine("shortcode : " + dest);
              str.WriteLine("Message : " + messageIn);
              str.WriteLine("Operator :" + operatorNew);
              str.Flush();
          }
  
      }
  
  }
  catch(Exception ex)
  {
      Response.Write(ex.Message);
  }
  
  
  }
  </code></pre>