Open a text file in Notepad
-
I have a windows app in which I want to open a text file in Notepad. When a button is clicked, a file dialog must open which lets the user select a file to be opened in notepad. I know how to create an OpenFileDialog, but I don't know how to open the selected file in Notepad. How does one do this?
-
I have a windows app in which I want to open a text file in Notepad. When a button is clicked, a file dialog must open which lets the user select a file to be opened in notepad. I know how to create an OpenFileDialog, but I don't know how to open the selected file in Notepad. How does one do this?
Check out the Process class in the System.Diagnostics namespace. You should create a Process object, set its StartInfo properties to launch notepad and open your selected text file. Something like this.
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"C:\Windows\notepad.exe";
p.StartInfo.Arguments = @"C:\yourPath\yourTextFile.txt";
p.Start(); -
I have a windows app in which I want to open a text file in Notepad. When a button is clicked, a file dialog must open which lets the user select a file to be opened in notepad. I know how to create an OpenFileDialog, but I don't know how to open the selected file in Notepad. How does one do this?
Process.Start(filename)
opens the file in its default application, as if you double-clicked it in Windows Explorer. :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Process.Start(filename)
opens the file in its default application, as if you double-clicked it in Windows Explorer. :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Any idea how to do this in ASP.NET?