Sai
Sai

Reputation: 67

How to get the path of selected folder in vb .net?

I have created a small application in vb .net to load all the files present inside the current folder where my application is running. I want to customize this application in such a manner that, when the user right click on any folder my application name also should appear in that menu. When the user click's that option, all the files present inside that corresponding folder should get listed.

I have achieved this partially. I have added my application to the right click menu item of all folders. But when I click my application name, all the files present in the parent directory is listed. I want to customize my coding to receive the path of the selected folder. So, how to do that?

Upvotes: 1

Views: 1003

Answers (1)

J3soon
J3soon

Reputation: 3153

There's a whole tutorial on MSDN: Verbs and File Associations

For example, the open verb normally launches a program to open a file. The command string typically looks as follows: "My Program.exe" "%1"

You can get the parameters by the code below:

Public Sub Main(ByVal cmdArgs() As String)
    If cmdArgs.Length > 0 Then
        'Process the command.
        'cmdArgs(0) is program name
        'cmdArgs(1) is the path of your folder / file.
    End If
End Sub

For Windows Forms, please see this .You'll need a function like below:

Public Sub Main(ByVal cmdArgs() As String)
    'Process cmdArgs here (same as above)
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault(False)
    Application.Run(New Form1)
End Sub

Upvotes: 3

Related Questions