예제 #1
0
파일: Form1.cs 프로젝트: jthapa01/CSharp
        private void Retrieve_Click(object sender, EventArgs e)
        {
            //declare the action here
            Action <RichTextBox, string> RetrieveWithoutError;

            //define the action,  = method body
            RetrieveWithoutError = delegate(RichTextBox GC, string FC)
            {
                try
                {
                    GC.AppendText(File.ReadAllText(".\\GraficConsole.txt"));
                }
                catch (Exception)
                {
                    using (StreamWriter w = File.AppendText(FC))
                    {
                        ;
                    }
                }
            };

            GraficConsole.AppendText(Environment.NewLine + "using the Retrive Action here ..." + Environment.NewLine);
            //call the action here
            RetrieveWithoutError(GraficConsole, AppFiles.ConsoleTextFile.TheFileComplete);
        }