Sunday, April 26, 2009

Kill System Processors using vb.net

private sub killDuplicateProcess(pro_name as string)
Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName(pro_name)

For Each i As Process In pro
i.Kill()
Next

end sub

''This function kill the process of given name in system

Friday, November 14, 2008

Renam by File Extion

Private Function renameByExt()
Try
Dim new_ext As String = Me.txtNewExt.Text.Trim
Dim i As Integer = 0
For i = 0 To no_of_files - 1
Dim f As New System.IO.FileInfo(listFiles(folder_path)(i))
Dim temp_filename As String = listFiles(folder_path)(i)
temp_filename = temp_filename.Substring(temp_filename.LastIndexOf("\") + 1)
temp_filename = temp_filename.Substring(0, temp_filename.LastIndexOf("."))
Dim j As New System.IO.FileInfo(folder_save + "\" + temp_filename + "." + new_ext)
If Not j.Exists Then
f.CopyTo(folder_save + "\" + temp_filename + "." + new_ext)
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function