System.IO.File.AppendText C# (CSharp) Méthode

AppendText() public static méthode

public static AppendText ( String path ) : StreamWriter
path String
Résultat StreamWriter
        public static StreamWriter AppendText(String path)
        {
            if (path == null)
                throw new ArgumentNullException(nameof(path));
            Contract.EndContractBlock();

            return new StreamWriter(path, append: true);
        }

Same methods

File::AppendText ( string path ) : System.IO.StreamWriter

Usage Example

Exemple #1
0
 public void ItemDClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         FlowPanel.Controls.Remove((PictureBox)sender);
         Con.TryGetValue((PictureBox)sender, out string file);
         File.Delete(file);
         return;
     }
     if (e.Clicks > 1)
     {
         try
         {
             Con.TryGetValue((PictureBox)sender, out string file);
             Process          prc = new Process();
             ProcessStartInfo psi = new ProcessStartInfo(file);
             if (file.EndsWith(".lnk", StringComparison.OrdinalIgnoreCase))
             {
                 psi = new ProcessStartInfo(GetTargetPath(file));
                 psi.WorkingDirectory = GetWorkingDirectory(file);
                 psi.Arguments        = GetArgument(file);
             }
             if (psi.FileName.EndsWith(".exe") || psi.FileName.EndsWith(".msi"))
             {
                 if (UACChecker.RequiresElevation(psi.FileName))
                 {
                     psi.Verb = "runas";
                 }
             }
             if (psi.FileName == "")
             {
                 psi.FileName = file;
             }
             psi.UseShellExecute        = true;
             psi.RedirectStandardOutput = false;
             psi.RedirectStandardInput  = false;
             psi.CreateNoWindow         = false;
             prc.StartInfo = psi;
             prc.Start();
             Application.Exit();
         } catch (Exception ex)
         {
             using (StreamWriter sw = File.AppendText(Environment.CurrentDirectory + @"\log.txt"))
             {
                 sw.WriteLine("[Error] Execution error with folder {0}!", L_Title.Text);
                 foreach (string line in ex.Message.Split('\n'))
                 {
                     sw.WriteLine("[Error] {0}", line);
                 }
             }
             DialogResult dr = MessageBox.Show(ex.Message, "Execution Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             if (dr == DialogResult.OK)
             {
                 Environment.Exit(1);
             }
             Thread.Sleep(2000);
         }
     }
 }
All Usage Examples Of System.IO.File::AppendText