.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to open a text file in a notepad, Using C#

Posted By:Sajid P K       Posted Date: November 02, 2010    Points: 15    Category: File Operation    URL: http://www.dotnetspark.com  

This Code segment explains How to create and Write to text file and also it shows, how opens it in notepad form C# Code.
 

 //Create a File           
 System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\log.txt");    

//Writing to file - Start    
 sw.WriteLine("Start...");   
 sw.WriteLine("Sample content");   
 sw.WriteLine("---------------"); 
 sw.WriteLine("---------------");            
 sw.WriteLine("End...");    
//Writing to file - End    

//Flusing and Disposing the file object   
  sw.Flush();          
  sw.Close();        

//opening file in notepad           
 System.Diagnostics.Process.Start(@"C:\windows\system32\notepad.exe", @"C:\log.txt");

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend