Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Kucich
  10. {
  11.     class FileTesto
  12.     {
  13.         private string nomeFile;
  14.  
  15.         public FileTesto(string nomeFile)
  16.         {
  17.             this.nomeFile = nomeFile;
  18.         }
  19.  
  20.         public string NomeFile
  21.         {
  22.             set
  23.             {
  24.                 nomeFile = value;
  25.             }
  26.             get
  27.             {
  28.                 return nomeFile;
  29.             }
  30.         }
  31.  
  32.         public void Crea()
  33.         {
  34.             if (!File.Exists(nomeFile))
  35.             {
  36.                 StreamWriter file = new StreamWriter(nomeFile, false);
  37.                 file.Close();
  38.             }
  39.         }
  40.  
  41.         public void Scrivi(string riga)
  42.         {
  43.             StreamWriter file = new StreamWriter(nomeFile, true); // append
  44.             file.WriteLine(riga);
  45.             file.Close();
  46.         }
  47.  
  48.         public ArrayList Leggi()
  49.         {
  50.             string riga;
  51.             ArrayList list = new ArrayList();
  52.             StreamReader file = new StreamReader(nomeFile);
  53.  
  54.             while (!file.EndOfStream)
  55.             {
  56.                 riga = file.ReadLine();
  57.                 list.Add(riga);
  58.             }
  59.             file.Close();
  60.             return list;
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement