daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Dec 19th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             string dat1 = @"C:\Users\Fabian\Desktop\Eingabe.txt";
  2.             string dat2 = @"C:\Users\Fabian\Desktop\Augabe.txt";
  3.  
  4.             int anz = 0,pos = 0;
  5.             StreamReader sr = new StreamReader(dat1, false);
  6.             Console.Write("Suche: ");
  7.             string suche = Console.ReadLine();
  8.  
  9.             string zeile = sr.ReadToEnd();
  10.  
  11.             do
  12.             {
  13.                 pos = zeile.IndexOf(suche);
  14.                 if (pos > -1)
  15.                 {
  16.                     anz++;
  17.                     zeile = zeile.Substring(pos + suche.Length);
  18.                 }
  19.             } while (pos > -1);
  20.  
  21.             sr.Close();
  22.             Console.WriteLine(suche + " wurde in der Datei Eingabe.txt " + anz + " mal gefunden");
  23.  
  24.            
  25.  
  26.  
  27.             StreamWriter sw = new StreamWriter(dat2, false);
  28.  
  29.             sw.Write(anz);
  30.  
  31.             sw.Flush();
  32.             sw.Close();
  33.  
  34.             Console.ReadLine();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top