A Button to open folder

  • 13 years ago

    Hi People,

     Pls. help with the situation –  Is it possible to have a button on the form which is if pressed would open a folder under the pre-stored path? Could anyone help? Thanks in advance. Holmes.vk

     

  • 13 years ago

    Hi Holmes,

    There is a possible way to open a folder by clicking on a button under the pre-stored path. Let say you want to open a folder name "C:\Program Files\Ares". First you need to declare ShellExecute.

    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (Byval hWnd as Long...)

    Then you need to do this code:

    Sub OpenFolder (strURL as String, iWindowStyle as Integer, fH as Long)

    Dim Folder as Long

    Folder = ShellExecute(fH, "Open", strURL, 0&, 0&, iWindowStyle)

    End Sub

    Then on the command button code you need to put this line;

    Call OpenFolder ("C:\Program Files\Ares", 10, 1)

    You can try this code and it work very well in my previous project.

  • 13 years ago

    Thank you for your hepl!

    Regards.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” - Tom Cargill