Results 1 to 11 of 11

Thread: FYI: SHBrowseForFolder assembly

  1. #1

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    FYI: SHBrowseForFolder assembly

    Hi guys,
    I thought you might find this interesting. After getting thoroughly frustrated with the complexity of making the SHBrowseForFolder API work, I did a search on GotDotNet and found the attached example.

    It's really cool and complete. If you find this useful, cheers!

    I'm giving acknowledgement to vrk75 whoever he may be. There's not much else for a reference.
    Attached Files Attached Files
    -scott
    he he he

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    or you could always my BrowseForFolder class with a lot less lines of code

    Code:
    using System.Windows.Forms;
    using System.Windows.Forms.Design;
    
    public class BrowseForFolder : FolderNameEditor 
    { 
    	FolderNameEditor.FolderBrowser fBrowser = new System.Windows.Forms.Design.FolderNameEditor.FolderBrowser(); 
    
    	public BrowseForFolder()
    	{ 
    	
    	}
    	
    	public string ShowIt()
    	{
    		fBrowser.Description = "Choose A Directory...";
    		fBrowser.ShowDialog();
    		return fBrowser.DirectoryPath;
    	}
    
    
    	~BrowseForFolder()
    	{
    		fBrowser.Dispose(); 
    	}
    
    }

    usage
    Code:
    BrowseForFolder go = new BrowseForFolder();
    MessageBox.Show(go.ShowIt());
    now tell me...who da man?

    <starts flexing muscles and posing>

    thank god once again for WinCV...LOL
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    Originally posted by Cander
    or you could always my BrowseForFolder class with a lot less lines of code

    Code:
    using System.Windows.Forms;
    using System.Windows.Forms.Design;
    
    public class BrowseForFolder : FolderNameEditor 
    { 
    	FolderNameEditor.FolderBrowser fBrowser = new System.Windows.Forms.Design.FolderNameEditor.FolderBrowser(); 
    
    	public BrowseForFolder()
    	{ 
    	
    	}
    	
    	public string ShowIt()
    	{
    		fBrowser.Description = "Choose A Directory...";
    		fBrowser.ShowDialog();
    		return fBrowser.DirectoryPath;
    	}
    
    
    	~BrowseForFolder()
    	{
    		fBrowser.Dispose(); 
    	}
    
    }

    usage
    Code:
    BrowseForFolder go = new BrowseForFolder();
    MessageBox.Show(go.ShowIt());
    now tell me...who da man?

    <starts flexing muscles and posing>

    thank god once again for WinCV...LOL

    you been hacking my computer
    ?
    just you stole that from me

    damn it

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    liar. trying to take credit for my hard earned work

    Seriously though, did you have something like it? I have yet to see anyone else do it without API yet
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327
    nice one!

    It does everything but select a user specified initial directory...
    -scott
    he he he

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    the class i inherited actually has that method/property..ill add that to he class
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327
    Cander,
    I looked at it and it doesn't have what I'm looking for. You can set the startup dir to a special windows folder, but not to a user defined path (like "c:\MyFolder"). You can correct me if I'm wrong, but the StartLocation property is just an FolderBrowserFolder Enum.

    Check it out....
    -scott
    he he he

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    yeah i noticed that..hmmm..
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    Originally posted by Cander
    liar. trying to take credit for my hard earned work

    Seriously though, did you have something like it? I have yet to see anyone else do it without API yet
    yep i do and i was gonna commment it n release it
    good job dude

    you know i lost so many of the class i wrote (forgot to back them up during format)
    so i have to rewrite most of them
    grrrrrr

  10. #10
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    D'OH! I lost alot of code once..it only takes once before you really leanr your lesson about back ups!
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  11. #11
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    usually am very good at backing up
    but EVERY TIME there is ONE thing that i forget
    hehe
    and that happened to be a vs project with lot of classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width