How to delete the program (Author: Zhu Xinbin, Zhao Xi 2005.2.27)
Private sub button#click (byval sender as system. Object, byval e as system. eventargs) handles button1.click
Dim delstring as string 'string of the batch file to be written
Dim appname as string
Appname = system. environment. getcommandlineargs (0). Replace (directory. getcurrentdirectory ()&"/","")
Delstring = "pause" & vbcrlf ', which can be changed. The batch processing file can be executed after a period of time. Otherwise, it cannot be deleted if the program is not exited.
Delstring + = "Del" & appname & vbcrlf 'to generate a program deletion command. The intermediate part is used to obtain the complete program path.
Delstring + = "del % 0" 'Delete the BAT file
Dim delbatfile as new filestream ("delme. Bat", filemode. Create) 'generates a bat batch file
Dim buffer (100) as byte
Buffer = system. Text. encoding. ASCII. getbytes (delstring. tochararray) 'converts a string to a byte stream
Delbatfile. Write (buffer, 0, buffer. Length) 'write to the BAT file
Delbatfile. Flush ()
Delbatfile. Close ()
Process. Start ("delme. Bat") 'executes batch processing files
Me. Close ()
End sub