Groups | Blog | Home
all groups > vb.net controls > october 2004 >

vb.net controls : Termination of a file


Tor Inge Rislaa
10/22/2004 2:23:41 PM
Hi I am using the code below to execute a file in the program corresponding
to its filetype. Is there a way that I can control the termination of a file
and it's corresponding program. E.g. if I open the file "c:\data\test.txt"
it will open in the notepad. On my command from VB.NET I want to close the
file and the program notepad. Is this possible?

Public Sub ExecuteFile(ByVal strPath As String)

On Error GoTo errHandler

Dim p As New System.Diagnostics.Process()

Dim s As New System.Diagnostics.ProcessStartInfo(strPath)

s.UseShellExecute = True

s.WindowStyle = ProcessWindowStyle.Normal

p.StartInfo = s

p.Start()

Exit Sub

errHandler:

Beep()

'Do somthing

End Sub



TIRislaa

Herfried K. Wagner [MVP]
10/22/2004 3:15:10 PM
"Tor Inge Rislaa" <nospam.tor.inge@rislaa.no> schrieb:
[quoted text, click to view]

\\\
Dim p As Process = Process.Start("C:\WINDOWS\WIN.INI")
p.WaitForExit()
MsgBox("Closed!")
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Tor Inge Rislaa
10/22/2004 4:04:08 PM
This is OK for monitoring the termination, but how to force the termination
from my appliccation?

TIRislaa

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> skrev i melding
news:eNseokDuEHA.1048@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Herfried K. Wagner [MVP]
10/22/2004 4:11:19 PM
"Tor Inge Rislaa" <nospam.tor.inge@rislaa.no> schrieb:
[quoted text, click to view]

\\\
p.CloseMainWindow()
///

--
Herfried K. Wagner [MVP]
AddThis Social Bookmark Button