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.