I want to open a free pascal or turbo pascal file that has a .pas extension from a wpf application.
3 Answers
If you want to open
the editor associated with a file, then just do:
System.Diagnostics.Process.Start(path);
Where path
is the FQN of the .pas
file.
Basically, Windows will look for a program that is registered to view/edit the type (extension) of file when its not an executable. It will then create a new process passing the file name to the viewer/editor. See http://support.microsoft.com/kb/307859 for more info.
OR if by open
, you mean making your WPF application the default program associated with .pas
files. Then you need to make a few registry changes. This SO question provides the details.
OR if by open
, you mean reading the file, then try System.IO.File.ReadAllLines
or System.IO.File.ReadAllText
. More info at File method.

- 1
- 1

- 34,944
- 9
- 57
- 73
-
By open I mean "open the editor associated" , so it was the first one ,thanks for your help – Manal Apr 28 '14 at 23:38
-
there is no `File.ReadAllTextLines` - there's `File.ReadAllText` and `File.ReadAllLines` though – Andrew Apr 29 '14 at 05:47
string[] lines = File.ReadAllLines("C:\input.pas");
For more information about File
class, have a look at the resource here:
http://msdn.microsoft.com/en-us/library/system.io.file%28v=vs.110%29.aspx

- 3,648
- 1
- 15
- 29
May be below code would help
using System.IO;
FileStream fileStream = new FileStream(@"C:\input.pas", FileMode.Open);

- 11,625
- 3
- 43
- 61
-
It doesn't work, but when try this "System.Diagnostics.Process.Start(path);" I get what I want – Manal Apr 28 '14 at 23:45