-3

I want to open a free pascal or turbo pascal file that has a .pas extension from a wpf application.

DIF
  • 2,470
  • 6
  • 35
  • 49
Manal
  • 19
  • 4
  • Welcome to Stack Overflow. This is not a good way to ask a question here. Did you try _anything_ so far to solve your problem? Show your effort first so people might show theirs. Please read [FAQ], [ask] and [help] as a start.. – Soner Gönül Apr 28 '14 at 06:26

3 Answers3

4

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.

Community
  • 1
  • 1
Richard Schneider
  • 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
2
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

Andrew
  • 3,648
  • 1
  • 15
  • 29
0

May be below code would help

 using System.IO;

    FileStream fileStream = new FileStream(@"C:\input.pas", FileMode.Open);
Neel
  • 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