Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. public static void DeleteCategory(String category, bool withPassword = true, String destination = "Misc")
  2.         {
  3.             using (StreamReader reader = new StreamReader(
  4.                                                                    _fileStream,
  5.                                                                    Encoding.Unicode,
  6.                                                                    detectEncodingFromByteOrderMarks: true,
  7.                                                                    bufferSize: 4096,
  8.                                                                    leaveOpen: true
  9.                                                          )
  10.                    )
  11.             {
  12.  
  13.                 if (withPassword == true)
  14.                 {
  15.                     _fileStream.Position = _fileStream.Seek(0, SeekOrigin.Begin); // Metodo che cancella tutte le password se withPassword è true
  16.                     String strcat, strlabel, strline;
  17.                     while (!reader.EndOfStream)
  18.                     {
  19.                         strline = reader.ReadLine();                                            // Salvo la linea letta
  20.                         strlabel = strline.Substring(strline.IndexOf('.'));                     // Creazione di una sottostringa a partire dal punto
  21.                         strcat = strline.Substring(0, strline.Length - strlabel.Length);        // Creazione di una sottostringa a partire dall'inizio di strline che ha lunghezza pari a quella di strline - strlabel
  22.                         if (strcat == category)
  23.                             RemovePass(strlabel, strcat);
  24.                     }//while
  25.                 }//if
  26.                 else
  27.                 {
  28.  
  29.                 }
  30.             }//using
  31.            
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement