473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

View file based on it's file type - extension

I pass a filename to a method which needs to open that file up with the
aPPlication associated with that filename. If the file MyFile.txt then the
method should open it up in Notepad,. If MyFile.doc is passed then it should
be open up in MS Word.
I am using vs2005.
Aug 29 '08 #1
3 1225
On Fri, 29 Aug 2008 09:43:02 -0700, Ryan <Ry**@discussions.microsoft.com>
wrote:
I pass a filename to a method which needs to open that file up with the
aPPlication associated with that filename. If the file MyFile.txt then
the
method should open it up in Notepad,. If MyFile.doc is passed then it
should
be open up in MS Word.
Use the Process class, passing the document name as the
ProcessStartInfo.FileName used. As long as you don't change the default
value of ProcessStartInfo.UseShellExecute from "true", the Process class
will use the Windows Explorer shell's file type associations to launch the
appropriate program.

Pete
Aug 29 '08 #2
On Aug 29, 1:09*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 29 Aug 2008 09:43:02 -0700, Ryan <R...@discussions.microsoft.com>*
wrote:
I pass a filename to a method which needs to open that file up with the
aPPlication associated with that filename. *If the file MyFile.txt then *
the
method should open it up in Notepad,. If MyFile.doc is passed then it *
should
be open up in MS Word.

Use the Process class, passing the document name as the *
ProcessStartInfo.FileName used. *As long as you don't change the default *
value of ProcessStartInfo.UseShellExecute from "true", the Process class *
will use the Windows Explorer shell's file type associations to launch the *
appropriate program.

Pete
The quick and dirty method is to:

Process.Start("filename");
Aug 29 '08 #3
Thanks to both of you.

"za***@construction-imaging.com" wrote:
On Aug 29, 1:09 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 29 Aug 2008 09:43:02 -0700, Ryan <R...@discussions.microsoft.com>
wrote:
I pass a filename to a method which needs to open that file up with the
aPPlication associated with that filename. If the file MyFile.txt then
the
method should open it up in Notepad,. If MyFile.doc is passed then it
should
be open up in MS Word.
Use the Process class, passing the document name as the
ProcessStartInfo.FileName used. As long as you don't change the default
value of ProcessStartInfo.UseShellExecute from "true", the Process class
will use the Windows Explorer shell's file type associations to launch the
appropriate program.

Pete

The quick and dirty method is to:

Process.Start("filename");
Aug 29 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayne | last post by:
I'm using the following code from the Access Web to open a folder. The folder opens in "List" View. Is there an addition that I can make to the code to force the folder to open in "Details" view?...
0
by: Brian Henry | last post by:
I am using the following code to get the "Type" of a file Imports System.Runtime.InteropServices Public Class ShellAPI Public Declare Auto Function SHGetFileInfo Lib "shell32.dll" ( _ ...
1
by: Brian Henry | last post by:
Just thought maybe someone here would like to know this. It's an example code I just created quickly on how to figure out the name of a type of file based on its extension (say for example .DOC)...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
4
by: Mark | last post by:
Can anyone tell me how i can prevent that users can see my connection string to mysql database? Using my browser i could easely use the function: view source.....showing the html/php code. ...
5
by: mike | last post by:
Hi, I have been playing with VB.NET/C# for getting some general properties of a fileinfo object. However, FileInfo object does not seem to expose some of the basic properties like TYPE that used...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
13
by: Bill Nguyen | last post by:
Is it possible to create your won XSD to use with .NET based on an XML content? For example the one below: <?xml version="1.0"?> <pcats:FuelsDoc...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
1
by: tinman77 | last post by:
Thanks in advance for everyone's help... My problem is that more often than I would like, I get attachments that for some reason or another do not include an extension. What I want to do is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.