try{Console.WriteLine("———————————————————————————————————————————");Console.WriteLine("Program to perform the operations on a file");Console.WriteLine("———————————————————————————————————————————");FileStreamf=newFileStream("/home/kodingwindow/Trial.txt",FileMode.Append);//"Hi There!" text is present in Trial.txtStreamWriterw=newStreamWriter(f);w.WriteLine("Welcome to Kodingwindow!");w.Close();f.Close();FileStreamfs=newFileStream("/home/kodingwindow/Trial.txt",FileMode.Open);StreamReaderr=newStreamReader(fs);stringline="";while((line=r.ReadLine())!=null){Console.WriteLine(line);}r.Close();fs.Close();Console.WriteLine("———————————————————————————————————————————");}catch(FileNotFoundException){Console.WriteLine("File not found");}catch(Exceptione){Console.WriteLine(e);}finally{Thread.Sleep(5000);}
Output
kodingwindow@kw:~/csharp$ dotnet run
———————————————————————————————————————————
Program to perform the operations on a file
———————————————————————————————————————————
Hi There!
Welcome to Kodingwindow!
———————————————————————————————————————————
kodingwindow@kw:~/csharp$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, you need to install apk manually. Would you like to get the app? Minimum Requirement(s): Android 10