Alternative to FolderBrowserDialog

C

Conan Kelly

Hello all,

I hope this is the right NG to post this question in!!! (if there is a
better one, please let me know)

I'm using VB.NET in a Script Task in an SSIS Package (SQL Server 2005
Integration Services).

I found the FolderBrowserDialog Class and I think that is almost exactly
what I want (I'm browsing for a folder...not a file).

The only issue I'm having with FolderBrowserDialog is the RootFolder
property. It appears that my only options for RootFolder is special folders
(My Computer, My Documents, Desktop, etc...). The problem is the folder I
want to start in is not a special folder...it is a network share
(\\Server\Share\Subfolder). RootFolder won't accept this.

A much better option would be the FolderBrowserDialog with an
InitialDirectory property (just like the one in the OpenFileDialog). I
don't suppose there is anything out there like that?

Right now my work-around is using the OpenFileDialog and selecting a file
with in the folder that I want to process. Then (using LEFT(), INSTRREV(),
& LEN()) I get the folder from the path of the file. I don't care for this
and would much rather use something like the FolderBrowserDialog.

Thanks for any help anyone can provide,

Conan Kelly
 
A

Alex Petrov

Hi,

If you need to specify root folder (not initially selected one) at dialog
startup, you can try to use CaFolderDialog component from Dialog
Workshop.NET (details are available on www.componentage.com) and specify
RootFolder property (string type in this component and allows you to specify
any file system folder).

If you need to specify initially selected folder, then yes, SelectedPath
property is what you need.

Help it helps,
Alex Petrov

"Conan Kelly" <[email protected]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ ×
ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:[email protected]...
 
C

Conan Kelly

Stephany,

Thank you for your feedback.

After trying your suggestion, this is what showed up when the ShowDialog()
method was executed:
http://home.att.net/~ctbarbarin/files/FolderBrowserDialog.JPG

I tried almost every combination of the displayed lines of code that I could
think of, but nothing worked...so I can't imagine that it has anything to do
with your suggestion.

My code is as follows:

Imports System
Imports System.Data
Imports System.Math
Imports System.Windows.Forms
Imports System.Environment.SpecialFolder
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain
Public Sub Main()
Dim pstrFolderPath As String
Dim pfbdFolder As New FolderBrowserDialog

pfbdFolder.RootFolder = MyComputer
pfbdFolder.SelectedPath = "\\Server\Development\Projects\Client\"
pfbdFolder.Description = "Please select a folder that contains the files
you want to import."
pfbdFolder.ShowDialog()
pstrFolderPath = pfbdFolder.SelectedPath
Dts.Variables("varFolderPath").Value = pstrFolderPath

Dts.TaskResult = Dts.Results.Success
End Sub
End Class


Am I doing something wrong that is causing this blank Folder Browser Dialog?
Is there a recent update to the .NET framework that could be causing this
(my computer has all updates (to date) installed)? I think I remember
messing around with the FolderBrowserDialog before and seeing a window with
a folder tree then.

Thanks again for all of your help,

Conan
 
C

Conan Kelly

Alex,

Thank you for your feedback.

After trying your suggestion, this is what showed up when the ShowDialog()
method was executed:
http://home.att.net/~ctbarbarin/files/FolderBrowserDialog.JPG

I tried almost every combination of the displayed lines of code that I could
think of, but nothing worked...so I can't imagine that it has anything to do
with your suggestion.

My code is as follows:

Imports System
Imports System.Data
Imports System.Math
Imports System.Windows.Forms
Imports System.Environment.SpecialFolder
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain
Public Sub Main()
Dim pstrFolderPath As String
Dim pfbdFolder As New FolderBrowserDialog

pfbdFolder.RootFolder = MyComputer
pfbdFolder.SelectedPath = "\\Server\Development\Projects\Client\"
pfbdFolder.Description = "Please select a folder that contains the files
you want to import."
pfbdFolder.ShowDialog()
pstrFolderPath = pfbdFolder.SelectedPath
Dts.Variables("varFolderPath").Value = pstrFolderPath

Dts.TaskResult = Dts.Results.Success
End Sub
End Class


Am I doing something wrong that is causing this blank Folder Browser Dialog?
Is there a recent update to the .NET framework that could be causing this
(my computer has all updates (to date) installed)? I think I remember
messing around with the FolderBrowserDialog before and seeing a window with
a folder tree then.

Thanks again for all of your help,

Conan
 
S

Stephany Young

You sure are doing something wrong!

..RootFolder = System.Environment.SpecialFolder.MyComputer and .SelectedPath
= <a UNC path> are mutually exclusive.

To set .SelectedPath = <a UNC path> you need to be able to navigate to
'Network' in the tree.

Create a small test harness, and leave .SelectedPath blank. In turn, set
..RootFolder to each of the System.Environment.SpecialFolder enumerated
values and observe the behaviour.

You should note that you cannot 'climb' above the 'root'.

Also note that 'Network' is not a member of System.Environment.SpecialFolder
and that the onlt 'root' value that allows you to get at 'Network' is
'Desktop'.

Therefore set .RootFolder = System.Environment.SpecialFolder.Desktop and all
should be well.
 
C

Conan Kelly

Stephany,

Thanks again for your help.

Please check this code:



Imports System
Imports System.Data
Imports System.Math
Imports System.Windows.Forms
Imports System.Environment.SpecialFolder
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain

Public Sub Main()
Dim pstrFolderPath As String
Dim pfbdFolder As New FolderBrowserDialog

pstrFolderPath = ""

'pfbdFolder.RootFolder = MyComputer
'pfbdFolder.RootFolder = Desktop
'pfbdFolder.RootFolder = ApplicationData
'pfbdFolder.RootFolder = CommonApplicationData
'pfbdFolder.RootFolder = CommonProgramFiles
'pfbdFolder.RootFolder = Cookies
pfbdFolder.RootFolder = DesktopDirectory

'pfbdFolder.SelectedPath = "\\Server\Development\Projects\Client\"
pfbdFolder.Description = "Please select a folder that contains the files
you want to import."
pfbdFolder.ShowDialog()
pstrFolderPath = pfbdFolder.SelectedPath

'Dts.Variables("varFolderPath").Value = pstrFolderPath

Dts.TaskResult = Dts.Results.Success
End Sub
End Class



You should be able to tell which .SpecialFolder enumerated values that I've
tried. Leaving the ".SelectedPath" line commented out each time, I got the
exact same blank Folder Browser Dialog I showed you earlier each time I ran
this. So, right now, .SelectedPath isn't even in the picture. I even tried
this with no .RootFolder line and still got a blank dialog.

"Something" else is causing a blank Folder Browser Dialog. Is this
"Something" in my code........or could this "Something" have to do with an
update to the .NET Framwork?

I guess I will first get the Folder Browser Dialog working correctly, and
then work on the .SelectedPath after that.

Thanks again,

Conan
 
S

Stephany Young

I can't reproduce your problem with the blank dialog.

I get exactly the results I expect.

Whatever else might be wrong with your project is beyond the scope of this
thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top