Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO; // przesztreń nazw zapewniająca odczytywaniu i zapisywanie do pliku
- namespace zad_1
- {
- public class Program
- {
- static FileStream fs; // zapewnia zapis, odczyt pliku
- static StreamWriter sw;
- public static void zapis(string imie, string nazwisko, decimal rok)
- {
- fs = new FileStream("D:\\!!!Studia\\Semestr 4\\Moje\\Informatyka\\Labki\\lab_7\\message3.txt", FileMode.Append, FileAccess.Write);
- sw = new StreamWriter(fs);
- sw.WriteLine(imie + " " + nazwisko + " " + " " + rok); // zapisaniu ciągu tekstowego
- sw.Flush(); // czyści bufory i zapisuje do pliku
- sw.Close(); // zamyka obiekt i czyści strumień
- fs.Close(); //zamyka strumień i zwalnia zasoby
- }
- public static string odczyt()
- {
- StreamReader sr = new StreamReader("D:\\!!!Studia\\Semestr 4\\Moje\\Informatyka\\Labki\\lab_7\\message3.txt");
- String line = sr.ReadToEnd(); // odczytuje znaki od bieżącej pozycji do końca
- //Console.WriteLine(line);
- // sr.BaseStream.Position = 0; // powrót na początek pliku
- /* string[] words = line1.Split(' ', '\t');
- foreach (string word in words)
- {
- Console.WriteLine(word);
- }
- */
- sr.Close();
- return line;
- }
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement