Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open Text File in Wordpad

Posted on 2009-06-30
13
Medium Priority
?
522 Views
Last Modified: 2012-05-07
How can I open a text file via Wordpad in C#.  The code I'm using below compiles fine, but nothing happens when I attempt to launch Wordpad.
string strLogFilePath = @"c:\dir\subdir\file.txt";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process = System.Diagnostics.Process.Start("wordpad", strLogFilePath);

Open in new window

0
Comment
Question by:thegreekitalian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
13 Comments
 
LVL 5

Expert Comment

by:iUsername
ID: 24749681
What happens if you run:

System.Diagnostics.Process.Start(@"C:\Program Files\Windows NT\Accessories\wordpad.exe", strLogFilePath);

???
0
 
LVL 39

Expert Comment

by:abel
ID: 24749700
you do not need your line 2, that a redundant "new" statement.

Just tried your code, works perfect for me. What errors do you get?
0
 

Author Comment

by:thegreekitalian
ID: 24749763
abel,
I don't get an error, I get nothing at all.
private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("wordpad", strLogFilePath);
        }

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:thegreekitalian
ID: 24749770
iUsername,

The same thing happens... which is absolutely nothing.
0
 
LVL 39

Expert Comment

by:abel
ID: 24749794
Just as experiment, can you past the following line and execute it from the immediate window to see if that works (it doesn't matter that the file does not exist)?

System.Diagnostics.Process.Start("wordpad", "test.txt");

(for the immediate window to work, your application must be error free and have the Startup focus).

When that works, can you place a breakpoint on line 3 in your last post and run your application? When it hits the breakpoint, can you copy the line from the breakpoint line in the imm. window and execute it (hit enter)? If that works, can you hit F10 to go to the next line? If that works.... (but it shouldn't, let's see how far you get).
0
 
LVL 39

Expert Comment

by:abel
ID: 24749811
PS: if wordpad could not be found or started (just tested that), you will get an exception.
0
 

Accepted Solution

by:
thegreekitalian earned 0 total points
ID: 24750096
Still not working.  Tired of messing with it.  I just created a multi-line text box control that I'll read the log file into.  Thanks for your help.
0
 
LVL 39

Expert Comment

by:abel
ID: 24750241
If you're running on Vista and you are not an administrator, you may've run into user-restriction problems. Also, does the breakpoint hit and what did the imm. window output? It should dump about 100 lines of useful information....

Oh, and have you already checked the task manager? And what happens if you go to a command window and type "start wordpad"? That uses the same command internally as Process.Start.

Well, if you don't want to pursue this further....
0
 

Author Comment

by:thegreekitalian
ID: 24750510
abel,

I already went ahead with the text box.  I appreciate your help, though.  Thank you.
0
 
LVL 39

Expert Comment

by:abel
ID: 25438308
Not sure why "a full refund" as the asker clearly answered this question himself: he went for another solution. This (s)he explains in http:#24750096 along with giving the other solution. My suggestion/request is to accept his comment as answer.

The question is valuable to keep because the other comments give insight in how to troubleshoot the original problem.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question