Calling .net function from lotusscript

Lotusscript is equipped with the OpenFileDialog method, which will return the name of a file, but I need to select a directory. I want to get a FolderBrowserDialog from a form in the notes client. FolderBrowserDialog is a .net function. How do I call it? Using the tip documented herehttp://www-01.ibm.com/support/docview.wss?uid=swg21230705

I wrote the code

Dim listOfFolders As Variant

Set listOfFolders = CreateObject(“FolderBrowserDialog”)

but I get an error “Cannot create automation object.” So Notes doesn’t know how to instantiate an object using that class. What step am I missing? How do I tell notes where it is?

Subject: Use Windows Shell instead

Dim objShell As VariantDim objFolder As Variant

Dim objFolderItem As Variant

Set objShell = CreateObject(“Shell.Application”)

Set objFolder = objShell.BrowseForFolder(0, “Please select a folder”, 0, “C:\Lotus\Notes”)

If Not (objFolder Is Nothing) Then

Set objFolderItem = objFolder.Self

Msgbox objFolderItem.Path	

End If

Subject: that worked

thanks, that fixed my problem. I’m still interested in the answer to my .net question, though, if anyone knows. I’d think I should be able to call on that FolderBrowserDialog.

Subject: Have you written the DLL?

It looks like from the article that you need to write a wrapper class in C# or VB.NET and call that. You can’t call the .NET method directly.

Subject: no. I haven’t written the dll

that’s what I was wondering. I was thinking there’s a way to call it directly without having to write a wrapper like in the example. The function I’m looking for is in System.Windows.Forms.dll, and that dll is registered, so I figured I could just use it. if the answer is that I have to write my own dll, that’s fine; I’d just like to confirm that.

Subject: you want the SHBrowseForFolder API call

The .Net runtime drops down to the Windows Shell API call SHBrowseForFolder, which you can call directly from LotusScript. No need to write a wrapper DLL.

More info can be found here: VBnet™ Visual Basic Developers Resource Centre. The code there is for VB5/6, not VB.Net, and can be relatively easily converted to LotusScript.