Advertisement
RupeshAcharya60

Creating and Reading Text File

Jun 15th, 2022
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. namespace ConsoleApp1
  4. {  
  5.  
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string writeText = "Learning C#";
  11.             //writing on file
  12.             File.WriteAllText("filename.txt",writeText);
  13.  
  14.             //path of file
  15.             //root_project_location vary where you save the project folder
  16.  
  17.             string path = @"[ROOT_PROJECT_LOCALION]\bin\Debug\filename.txt";
  18.             string readText = File.ReadAllText(path);
  19.             Console.WriteLine(readText);
  20.             Console.ReadKey();
  21.  
  22.         }
  23.  
  24.     }
  25.    
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement