Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. string Pfad = string.Empty;
  2.             OpenFileDialog openFileDialog1 = new OpenFileDialog();
  3.             openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files(*.*)|*.*";
  4.             if (openFileDialog1.ShowDialog() == DialogResult.OK)
  5.             {
  6.                 Pfad = openFileDialog1.FileName;
  7.             }
  8.  
  9.             int index = 0;
  10.             daten = new String[spalten.Length];
  11.             foreach (string item in spalten)
  12.             {
  13.                 for (int i = 0; i < spalten.Length; i++)
  14.                 {
  15.                     daten[i] = item;
  16.                 }
  17.             }
  18.  
  19.             if (!(tB_Name.Text == string.Empty || tB_Passwort.Text == string.Empty || tB_Login.Text == string.Empty))
  20.             {
  21.                 daten = new String[spalten.Length + 4];
  22.                 foreach (string item in spalten)
  23.                 {
  24.                     for (int i = 0; i < spalten.Length; i++)
  25.                     {
  26.                         daten[i] = item;
  27.                     }
  28.                 }
  29.  
  30.                 // ARRAY NEU ANLEGEN UND UM 3 ERWEITERN DANN WIRD EIN NEUER DATENSATZ HINZUGEFÜGT
  31.                 daten[spalten.Length + 1] = tB_Name.Text;
  32.                 daten[spalten.Length + 2] = tB_Login.Text;
  33.                 daten[spalten.Length + 3] = tB_Passwort.Text;
  34.             }
  35.  
  36.             System.IO.File.WriteAllText(Pfad, string.Empty);
  37.             for (int i = 0; i < daten.Length / 3; i++)
  38.             {
  39.                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(Pfad, true))
  40.                 {
  41.                     file.WriteLine(daten[index] + "," + daten[index + 1] + "," + daten[index + 2]);
  42.                 }
  43.                 index++;
  44.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement