Open a text file in C # programmatically

I want to open a text file programmatically using C #. I used:

System.Diagnostics.Process.Start(test.txt);

but this code causes a problem with entering an OS command when scanning for threats.

Is there any way I can open a text file programmatically? or a way around this injection of the operating system?

thank

+3
source share
1 answer

You should call the program, say, notepad:

Process.Start("notepad.exe", fileName);

argument is the file name:

 Process.Start("notepad.exe", "Test.txt");

See the code problem in the comments on this post: Open a file using Notepad in C #

+1
source

All Articles