944,204 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 62570
  • C# RSS
May 26th, 2005
0

C#ASP.Net: how to browse the folder list on Server?

Expand Post »
Hi,

I am writing a web app using C# and asp.net. The requirement is that: there is a button "browse" on the webform, when user click it, the folders on the server will be showed. after user select one folder, the fullpath of this folder will be returned. There is no web control could do that. does anybody know how to do it?

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
c#bird is offline Offline
5 posts
since May 2005
May 27th, 2005
0

Re: C#ASP.Net: how to browse the folder list on Server?

On the server side, you'd use Server.MapPath to specify the viritual path to your directory. Then perhaps DirectoryInfo.GetFiles to return a filelist. Iterate through that list to populate whatever Server Control you want to contain that data. A Repeater, perhaps.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
May 27th, 2005
0

Re: C#ASP.Net: how to browse the folder list on Server?

Quote originally posted by tgreer ...
On the server side, you'd use Server.MapPath to specify the viritual path to your directory. Then perhaps DirectoryInfo.GetFiles to return a filelist. Iterate through that list to populate whatever Server Control you want to contain that data. A Repeater, perhaps.
Probably I did not descript it clearly. There is a "browse" button on the web form, after I click it, there should be a folder selection dialog come out. It is quite like the "save as" dialog in windows but the different is that it could choose to select folder or select multiple files.

Thank you for your reply.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
c#bird is offline Offline
5 posts
since May 2005
May 27th, 2005
0

Re: C#ASP.Net: how to browse the folder list on Server?

You can let the user browse their LOCAL file system, and select a file to upload, via the <input type="file"> HTML tag. There is no equivalent to let a user browse the server's file system.

I understood your question. My answer was meant to show you that you'll have to code this yourself, and some of the .NET classes you could use to do so.

Left unstated is what the user would do with a file they selected. To know what they selected, you'll have to generate a PostBack / form submit, and then presumably serve them back the selected file via a Response.Redirect() to that file.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
May 30th, 2005
0

Re: C#ASP.Net: how to browse the folder list on Server?

Quote originally posted by tgreer ...
You can let the user browse their LOCAL file system, and select a file to upload, via the <input type="file"> HTML tag. There is no equivalent to let a user browse the server's file system.

I understood your question. My answer was meant to show you that you'll have to code this yourself, and some of the .NET classes you could use to do so.

Left unstated is what the user would do with a file they selected. To know what they selected, you'll have to generate a PostBack / form submit, and then presumably serve them back the selected file via a Response.Redirect() to that file.
Thanks for your reply. but the dialog box only let user select file not folder. How can I do to make the folder or file could be both returned? Would you pls give me some real code?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
c#bird is offline Offline
5 posts
since May 2005
May 31st, 2005
0

Re: C#ASP.Net: how to browse the folder list on Server?

No, I don't think I'll post any "real code". You're undertaking a sizable project, and that's a bit beyond the scope of coding for a forum example.

Quite simply, you have to duplicate the entire "open file dialog" box of the Win32 API. Such a thing just doesn't exist on the web. Web servers aren't built for this task. You'll have to code the entire graphic form, somehow using Web Server Controls... then populate the controls with the directory and file information. Then code all the events for when a user clicks a file or folder, each of which will require a server round-trip.

It's a big, big project. I think you'd be much better off making your project conform to the way the web works: give your users a list of hyperlinks.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Aug 8th, 2011
0

folder dialog box in asp.net

I am working on asp.net with c# and sql server.The scenario is like the user is taking the

backup of db and will store it in a particular loaction . now the issue is how to provide

the folder dialogbox to the user to select the location. we have file upload in asp.net but

that will allow me to uplaod the file on the db but i want the folder location in textbox

so that i can store the db over there. how will i do this.please help.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rv2011 is offline Offline
1 posts
since Aug 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Proper way to implement awaitable pattern of CTP async lib
Next Thread in C# Forum Timeline: updating for many to many relaitonship





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC