12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace Eserciziotep4
- {
- static class Gestione_File
- {
- static string Pacht = @"c:\document\pippo\";
- static string NomeFile = @"text.dat";
- static string Pachtd = Pacht + NomeFile;
- public static void MakeDirecotry()
- {
- try
- {
- Directory.CreateDirectory(Pacht);
- FileStream fs = File.Create(Pachtd);
- fs.Close();
- } catch (IOException e)
- {
- Console.WriteLine(e.Message);
- }
- }
- public static void Scrivi(string nome,string cognome)
- {
- try
- {
- //FileStream fe = File.OpenWrite(Pachtd);
- BinaryWriter bw = new BinaryWriter(File.Open(Pachtd,FileMode.Open));
- bw.Write(nome);
- bw.Write(cognome);
- bw.Close();
-
- }catch(IOException e)
- {
- Console.WriteLine(e.Message);
- }
- }
- public static string[] Leggi()
- {
- string c1=null;
- string[] p = new string[2];
- try
- {
- //FileStream fe = File.OpenRead(Pachtd);
- BinaryReader br = new BinaryReader((File.Open(Pachtd, FileMode.Open)));
- for (int i = 0; i < 2; i++)
- {
- c1 = br.ReadString();
- p[i] = c1;
- }
- br.Close();
- // fe.Close();
- }catch(IOException e)
- {
- Console.WriteLine(e.Message);
- }
- return p;
- }
-
- }
- }
|