"Kuldeep" <ku****************@hotmail.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>I am trying to browse folders through the following piece of code.
Please let me know if there is any kind of setting to get this working
right?
using shell32.dll;
Shell32.ShellClass shl = new Shell32.ShellClass();
Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, "Show
Folder", 0, System.Reflection.Missing.Value);
txtFolderName.Text = fld.Self.Path ;
yes it is on the server side.
You need to stop for a second and take one step back...
What does BrowseForFolder actually do?
Well, according to MSDN
(
http://msdn2.microsoft.com/en-us/library/ms630408.aspx) it "creates a
dialog box that enables the user to select a folder and then returns the
selected folder's Folder object."
That's fine, of course, for WinForms apps and client-side web functionality
(well, not really, but we'll let that pass...)
However, you're trying to run this server-side... Even if you do manage to
call the BrowserForFolder method, and even supposing it worked, who's
actually going to see the dialog box and select a folder?
What are you actually trying to do here? Presumably, a user visits one of
your pages and clicks a button (or something), and then needs to select a
folder for some reason...?
Where are these folders located? Does the account that ASP.NET is running
under even have permissions to to what you're trying to do...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net