Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to start an IE process so that the browser can launch the proper application after bringing the file into the browser in order to bring up the associated file.

 

code is as follows:

 

<code>

 

Process.Start("IExplore.exe", "C:\Temp\myFile.txt")

 

</code>

 

The file "C:\Temp\myFile.txt" exists on my local hard drive. It's a small text file.

 

No error occurs after the statement is executed. Another application doesn't for the file doesn't pop up at all.

 

How can I get the proper application to launch? What am I missing?

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

The process.start method is used to create multithreaded applications, not to execute files. The command you are looking for is Shell():

 

Shell("IExplore.exe C:\Temp\myFile.txt")

 

This should run internet explorer and throw the txt file in as an argument without any hassle.

 

Note that it wouldn't work properly on my own machine, as I have Windows XP x64 so that I have both a 32- and 64- bit iexplorer - VB can't figure out which one to launch, thus it gives a 404 error. I think it would be safer to specify the explorer's full path if possible.

Chaos is merely logic beyond human comprehension
  • Administrators
Posted (edited)

If you just launch the file itself the default application should be opened anyway,

System.Diagnostics.Process.Start("c:\\boot.ini");

launches boot.ini in notepad as that is the default text editor on my system.

 

You can also invoke any registered application through it's context menu verb like so

System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo("C:\\boot.ini");
si.Verb = "Print";
System.Diagnostics.Process.Start(si);

 

be aware that if you are running this on the server this will cause the application to be launched on the server not on the client's machine.

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I tried using that, but am consistently getting a "system.io.filenotfound" execption even though when I take that path string and put it inside internet explorer, the file comes up. So, I am sure the file exists.

 

Is the Shell command strictly for Windows or can it work on the web. If it supposedly can work on the web, it won't work with what I'm doing.....

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

  • Administrators
Posted

Is this running as part of an ASP.Net application? If so this code will execute on the server not the client pc.

If you are trying to get a client's browser to execute the above code then it cannot be done this way.

 

The Shell command is really just for compatability with VB6, Process.Start and the related classes are the prefered .Net way of doing things.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...