Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace ConsoleApplication82
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int opcija = 0;
  14. while (opcija != 7)
  15. {
  16. Console.WriteLine("********************************");
  17. Console.WriteLine("\t MENI");
  18. Console.WriteLine("********************************");
  19.  
  20. Console.WriteLine();
  21. Console.WriteLine();
  22. Console.WriteLine("1. - Kreiranje fajla");
  23. Console.WriteLine("2. - Upis sadrzaja sa komandne linije u fajl");
  24. Console.WriteLine("3. - Upis novog sadrzaja u fajl preko postojeceg sadrzaja");
  25. Console.WriteLine("4. - Ispis sadrzaja fajla na komandnoj linij");
  26. Console.WriteLine("5. - Brisanje sadrzaja fajla");
  27. Console.WriteLine("6. - Brisanje fajla uz provjeru da li fajl postoji");
  28. Console.WriteLine("7. - Izlaz");
  29.  
  30.  
  31.  
  32. string nazivFajla = "";
  33. string lokacija = @"D:\Vjezbe\" + nazivFajla + ".txt";
  34.  
  35. opcija = int.Parse(Console.ReadLine());
  36.  
  37. switch(opcija)
  38. {
  39. case 1:
  40. Console.WriteLine("Unesite naziv fajla: ");
  41. nazivFajla = Console.ReadLine();
  42. File.Create(lokacija);
  43. break;
  44. case 2:
  45. Console.WriteLine("Unesite sadrzaj koji zelite da upisete");
  46. string upis = Console.ReadLine();
  47. File.WriteAllText(lokacija, upis);
  48. break;
  49. case 3: break;
  50. case 4: break;
  51. case 5: break;
  52. case 6: break;
  53. case 7: break;
  54. default: Console.WriteLine("Unijeli ste pogresnu opciju"); break;
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement