gunsmokingman Posted February 24, 2010 Share Posted February 24, 2010 I have made this Vb.net app to run either Makecab or Expand, this app now displays the output of either function.Public Class Form1 Dim MeClose Dim MeLabel = Chr(187) & " Drag And Drop Single File Or Multiple Files. Drag And Drop A Single Folder Or Multiple Folders. This will auto sort the files for either Makecab or Expand process." Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = MeLabel Me.Text = "Gunsmokingman MakeCab And Expand Tool" ShowInfo(False) '-> To Accept Cmd Line Arguments EG '-> Start /Wait PATH_TO\MakeCabAndExpand.exe "SomeFileToCabOrExpand.zzz" '-> Run The App From Sendto Folder For Each Args In My.Application.CommandLineArgs If Args.Count >= 1 Then MeClose = True SortFileFolder(Args.ToString) End If Next '-> Close The App After Files Or Folder Are Completed If MeClose = True Then Me.Close() End If End Sub ''' <summary> ''' Change Status Bar Background ''' </summary> ''' <param name="Show"></param> ''' <remarks></remarks> Private Sub ShowInfo(ByVal Show As Boolean) If Show Then TxtInfo1.BackgroundImage = MakeCabAndExpand.My.Resources._125_LightLime Else TxtInfo1.BackgroundImage = MakeCabAndExpand.My.Resources._125_LightTan TxtInfo1.Text = "" End If End Sub ''' <summary> ''' Drag And Drop Action ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub Form1_Drag(ByVal sender As Object, ByVal e As DragEventArgs) Handles MyBase.DragEnter, MyBase.DragDrop If e.Data.GetDataPresent(DataFormats.FileDrop) Then Dim MyObject As String() = CType(e.Data.GetData(DataFormats.FileDrop), String()) Try For Each I In MyObject SortFileFolder(I.ToString) Next Catch ex As Exception End Try End If Label1.TextAlign = ContentAlignment.TopLeft Label1.Text = MeLabel End Sub ''' <summary> ''' Check Either A File Or Folder ''' </summary> ''' <param name="Chk"></param> ''' <remarks></remarks> Private Sub SortFileFolder(ByRef Chk) If Microsoft.VisualBasic.Right(InStr(Chk, "."), 5) Then Me.Focus() Work(Chk) Else Me.Focus() ListAll(My.Computer.FileSystem.GetFiles(Chk), My.Computer.FileSystem.GetDirectories(Chk)) End If End Sub ''' <summary> ''' List All Files From Parent Folder Threw All Sub Folders ''' </summary> ''' <param name="Files"></param> ''' <param name="Folders"></param> ''' <remarks></remarks> Private Sub ListAll(ByRef Files, ByRef Folders) For Each File In Files Work(File) Next For Each Folder In Folders ListAll(My.Computer.FileSystem.GetFiles(Folder), My.Computer.FileSystem.GetDirectories(Folder)) Next End Sub ''' <summary> ''' Makecab Or Expand Display Output To App ''' </summary> ''' <param name="File"></param> ''' <remarks></remarks> Private Sub Work(ByRef File) Environment.CurrentDirectory = My.Computer.FileSystem.GetParentPath(File) Dim F = Chr(34) & File.ToString & Chr(34) Dim Run As New Process() ShowInfo(True) If Not Microsoft.VisualBasic.Right(File, 1) = "_" Then '-> MakeCab Run.StartInfo.RedirectStandardOutput = True Run.StartInfo.UseShellExecute = False Run.StartInfo.CreateNoWindow = True Run.StartInfo.FileName = Environment.SystemDirectory & "\makecab.exe " Run.StartInfo.Arguments = " /D CompressionType=LZX /D CompressionMemory=21 " & F Run.Start() Label1.TextAlign = ContentAlignment.MiddleLeft Label1.Text = "Path : " & My.Computer.FileSystem.GetParentPath(File) & vbCrLf & _ "Name : " & My.Computer.FileSystem.GetFileInfo(File).Name Do MyBase.Update() TxtInfo1.Text = Run.StandardOutput.ReadLine.ToString() Me.Activate() Loop Until Run.HasExited Else '-> Expand Run.StartInfo.RedirectStandardOutput = True Run.StartInfo.UseShellExecute = False Run.StartInfo.CreateNoWindow = True Run.StartInfo.FileName = Environment.SystemDirectory & "\expand.exe " Run.StartInfo.Arguments = F & " /R" Run.Start() Label1.TextAlign = ContentAlignment.MiddleLeft Label1.Text = "Path : " & My.Computer.FileSystem.GetParentPath(File) & vbCrLf & _ "Name : " & My.Computer.FileSystem.GetFileInfo(File).Name Do MyBase.Update() TxtInfo1.Text = Run.StandardOutput.ReadLine.ToString() Me.Activate() Loop Until Run.HasExited End If If My.Computer.FileSystem.FileExists(File) Then My.Computer.FileSystem.DeleteFile(File, 2, 2) ShowInfo(False) End Sub '-> Close App Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End SubEnd ClassNew Source CodeMakeCabAndExpand.exe Link to comment Share on other sites More sharing options...
Sp0iLedBrAt Posted February 24, 2010 Share Posted February 24, 2010 (edited) Uses .NET Framework 3.5?Edit: after the primary error (no .NET 3.5), if I click Continue, it still works.Thank you very much, saves a lot of lines pointing Command Prompt to folders. Edited February 24, 2010 by Sp0iLedBrAt Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 24, 2010 Author Share Posted February 24, 2010 I made this on Windows 7 so i was not thinking about the framework version. Link to comment Share on other sites More sharing options...
Sp0iLedBrAt Posted February 24, 2010 Share Posted February 24, 2010 Please refer to the edited part of my first post here. Thank you again. Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 24, 2010 Author Share Posted February 24, 2010 Thank you Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 25, 2010 Author Share Posted February 25, 2010 If anyone has any suggestion as to improvements please post them here Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now