Start the associated application and open the special file zlyperson (original)-Windows development-. NET Tutorial-

Source: Internet
Author: User
Start the associated application and open the special file zlyperson (original)
    
The original article is C #. I changed it to VB, but it was not ready for testing. If you find any problems, please let me know.
This short article demonstrates how to start an application associated with a special file to open a special file without having to know the specific location and name of the associated application. For example, to open demo.bmp, mspaint.exe is usually associated with it in Windows. When VB. Net starts an associated application to open a special file, the. NetFrameWork System. Diagnostics namespace is required.
Next, we will construct a Starter for any associated program and create a VB file Starter. vb.
Imports System;
Imports System. IO;
Imports System. Diagnostics;
Public class Starter
Public shared sub new (args as string ())
'First, establish the process startup information structure
Dim pInfo as new ProcessStartInfo ();
PInfo. UseShellExecute = true;
Dim I as integer
For I = 0 to args. Length-1
If File. Exists (args [I]) then
PInfo. FileName = args [I];
'Start the process
Dim p as Process = Process. Start (pInfo );
End if
Next
End sub
End class
Compile Starter. vb
Run Starter test.bmp test.xls.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.