Wednesday, January 5, 2011

Create a text document and write data to the text document

  public static void WriteUserDetails(string data, string FileName)
        {
          
            try
            {

                FileStream fs = File.Open(FileName, FileMode.CreateNew, FileAccess.Write);



                // generate a file stream with UTF8 characters

                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);

                sw.WriteLine(data);
                sw.Flush();
                sw.Close();
            }
            catch
            {
               
                //GlobalData.SetApplicationExitState(true);
               
            }
        }

No comments:

Post a Comment