Browse Folder

  • Thread starter Thread starter Kuldeep
  • Start date Start date
K

Kuldeep

Framework: Visual Studio 2005
Technology: ASP.NET 2.0
Language: C#.NET 2.0

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 ;

Kindly advice

Kuldeep
 
yes it is on the server side.


Eliyahu Goldin said:
Are the folders you want to browse on client or server side? Your code is
apparently for server side.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Kuldeep said:
Framework: Visual Studio 2005
Technology: ASP.NET 2.0
Language: C#.NET 2.0

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 ;

Kindly advice

Kuldeep
 
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...?
 
yes it is on the server side.

message

Are the folders you want to browse on client or server side? Your code is
apparently for server side.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

- Show quoted text -

Shell32 is for "local usage"

Use System.IO

the code would be something like this

foreach (string s in Directory.GetFiles(Server.MapPath("/"), "*.*")
{
.....
}
 
Hi Mark,

I have a same requirement, I'm developing ASP.net application in C#,
framework 2.0 where I need to display a browse folder at client side. please
let me know how i can implement this web forms.

I have implemented a javascript code given in the url by you, but it is now
working and giving a javascript error "Permissions denied"

Ashish Khanna
 
I have a same requirement, I'm developing ASP.net application in C#,
framework 2.0 where I need to display a browse folder at client side.

That's not, actually, the same requirement - the OP was trying to use
client-side code to browse for folders server-side...
please let me know how i can implement this web forms.
I have implemented a javascript code given in the url by you, but it is
now
working and giving a javascript error "Permissions denied"

Slightly confused - you say "it is now working and giving a javascript
error" - it can't both be working *and* giving a javascript error... :-)

Please show your code.

Alternatively, have a look at this:
http://www.utechsoft.com/products/udownload/webdemo/index.html
 
Back
Top