www.pudn.com > ppc_edit-1.2-src.zip > TXT.cs


using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Windows.Forms; 
using System.IO; 
using Settings; 
 
namespace Modules 
{ 
    public static class TXT 
    { 
        public static void Save(String Text,UserSettings s) 
        { 
            /// 
            ///Handles file saving in Unicode TXT format. 
            /// 
            SaveFileDialog SaveDialog = new SaveFileDialog(); 
            SaveDialog.Filter = "Text file (*.txt)|*.txt"; 
            if (SaveDialog.ShowDialog() == DialogResult.OK) 
            { 
                StreamWriter sw = new StreamWriter(SaveDialog.FileName); //add extension 
                sw.Write(Text); 
                sw.Close(); 
                Messages.displaySaveMsg(SaveDialog.FileName, new Language(s.Language)); 
            } 
            return; 
        } 
 
        static public String Open() 
        {  /// 
            ///Opens UTF-8 encoded TXT file and returns its content 
            ///If user cancels the dialog, returns null 
            /// 
            { 
                OpenFileDialog ofd = new OpenFileDialog(); 
                ofd.Filter = "TXT file (*.txt)|*.txt"; 
                if (ofd.ShowDialog() == DialogResult.OK) 
                { 
                    StreamReader sr = new StreamReader(ofd.FileName); 
                    String Text = sr.ReadToEnd(); 
                    sr.Close(); 
                    return Text; 
                } 
                else  
                    return null; 
            } 
        } 
    } 
}