problem debugging program to read right-click folder

boesiii

New member
Joined
Feb 24, 2011
Messages
1
Programming Experience
Beginner
When I try and debug the code below, I get an error about the index being outside of the array. I tried to fix by inserting the length of the arrayin the () but it still does not work. The program will create a set of folders after the user right-clicks a folder in explorer and picks my program. Should I upload the entire code?

VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Hello text will show in textbox
        'TextBox1.Text = "Hello"
        'Dim dirPath As String = "c:\temp"
        Dim args() As String = Environment.GetCommandLineArgs()
        Dim dirPath As String = args(1)
        'tbCurrentFldr.Text = dirPath

    End Sub
 
Arrays are zero-based, so first item index is 0. Though you should first check that the array contains any items by the Length property. This is equally relevant for the return of GetCommandLineArgs where first item is the executable and the following, if any, are other command line arguments passed.
 
Back
Top