Win32Exception was Unhandled......

Hello Experts,

I have develop a small app for decompilation of chm's....but i am stuck at getting error as Win32Exception was unhandled.

Can you please help me to get rid of this, where i am wrong?

Please find below code for the same...

Imports System
Imports System.IO
Imports System.Data
Imports System.Security.AccessControl
Imports System.Diagnostics
Public Class Form1
    Private mstrFolderCHMFiles As String = ""
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim foldername As String
        If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            foldername = FolderBrowserDialog1.SelectedPath()
            Dim Results As DialogResult = FolderBrowserDialog1.ShowDialog
            If Results = Windows.Forms.DialogResult.Cancel Then
            End If
            Exit Sub
        End If
        mstrFolderCHMFiles = FolderBrowserDialog1.SelectedPath()
        txtinput.Text = foldername
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim filename As String
        Dim mydir As New DirectoryInfo(mstrFolderCHMFiles)
        Dim f As FileInfo() = mydir.GetFiles("*.chm")
        Dim i As Integer
        For i = 0 To f.Length - 1
            filename = f(i).FullName
            'Create folder based on filename
            Dim sDir As String = f(i).DirectoryName & "\" & f(i).Name.Replace(f(i).Extension, "")
            If Not (Directory.Exists(sDir)) Then
                Dim startinfo As New ProcessStartInfo
                Dim p As New Process
                startinfo.WindowStyle = ProcessWindowStyle.Normal
                startinfo.ErrorDialog = False
                startinfo.FileName = "C:\WINDOWS\hh.exe -decompile " + sDir + "   " + filename
                'startinfo.Arguments = "-decompile"
                'startinfo.Arguments = sDir
                'startinfo.Arguments = filename
                startinfo.UseShellExecute = False
                Process.Start(startinfo)                                ''''''getting error at this location...
            End If
        MsgBox("Decompilation Done!!")
    End Sub
End Class

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
Hi ShaileshShinde,

Try catching the error. Like this....

        Catch Win32ex As System.ComponentModel.Win32Exception
        End Try


ShaileshShindeAuthor Commented:
Hello Expert,

By adding above lines of code it shows an message as ...

The filename, directory name, or volume label syntax is incorrect..

Can you please help where the changes required..

mhm... try it this way:

startinfo.FileName = "C:\WINDOWS\hh.exe"
startinfo.Arguments = "-decompile " + sDir + "   " + filename

I think your problem may be that you mixed up filename and arguments!

Hope this helps!

Best regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShaileshShindeAuthor Commented:
Hello Expert,

This works now!!! Thanks a lot!!!

One more query related to this..

If i de-compile more than 5 chm's files... the process atr background is still running..where as i got the msg as decompilation done....

what was the cause of this...or any other way of doing this..

Mhm i would guess that (becouse of Process is working assynchrone) that you're simply starting processes faster than they can worked! Do the background processes close after a while?

best regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.