Manoj Maharana

Manoj Maharana

  • NA
  • 362
  • 128.1k

Notepad in C# (txt file)

Aug 11 2016 8:45 AM
public static void ShowMessage(DataTable message = null, string title = null)
{
Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
// Process notepad = System.Diagnostics.Process.Start(new ProcessStartInfo("notepad.exe", "txt_notes.Text"));
// Process notepad = System.Diagnostics.Process.Start(new ProcessStartInfo("notepad.exe", Environment.GetEnvironmentVariable("windir")));
// Process notepad = System.Diagnostics.Process.Start(new ProcessStartInfo("notepad.exe", "txt_notes.Text"));
//Process notepad = Process.Start(new ProcessStartInfo(@"c:\myfile.txt"));
notepad.WaitForInputIdle();
if (!string.IsNullOrEmpty(title))
SetWindowText(notepad.MainWindowHandle, title);
if (notepad != null)
{
if (message.Rows.Count > 0)
{
StringBuilder sb = new StringBuilder();
sb.Append("Notes : ");
sb.Append(message.Rows[0]["Notes"].ToString());
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append("Title : ");
sb.Append(message.Rows[0]["Title"].ToString());
Literal lt = new Literal();
lt.Text = sb.ToString();
IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, lt.Text);
}
}
}
 
The problem is that it is not working on server...
i want to show text file in notepad.
error comes 

Server Error in '/' Application.

Access is denied


Answers (13)