rfazendeiro Posted February 14, 2005 Posted February 14, 2005 Hi to all, i have searched the forum but did not find what i'm looking for. I'm new in ASP.NET so i need sime help here plz. What i what is to browse directories and not files. In html the <input type="file"> searches a specific file but what i want is to select a directory. I'm using vb.net so if you could give a help i would aprecciate. thx to all Quote
*Gurus* Derek Stone Posted February 14, 2005 *Gurus* Posted February 14, 2005 This is not possible using HTML. Quote Posting Guidelines
rfazendeiro Posted February 15, 2005 Author Posted February 15, 2005 I'm programming ASP.NET using VB and i need to browse for directories. I know that html is not the solucoes i only gave it as an example of file browse. does anyone know how to browse for directories allowing to choose one in asp.net? Quote
Administrators PlausiblyDamp Posted February 15, 2005 Administrators Posted February 15, 2005 If you are using ASP.Net the client is still only recieving HTML, and as such is limited to the standard HTML controls. Failing that you would need to investigate some other client side technology such as Java and provide your own custom UI. It may help if you gave more details about why you need to do this as there could be an alternate solution to your problem. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rfazendeiro Posted February 15, 2005 Author Posted February 15, 2005 Well what i want seems simple enough but i have some problems with directory browsing. So its this: The administrator of the aplication can upload images to the database. There will be a directory (not always the same) where the images will be put. The admin them browses to that directory and selects it. By doing that it will upload all images in that directory to the database. I cannot consider doing one by one because there could be alot of images. So i need to pick the directory and browse for all the files and upload them to the database. Any good ideas how to do this? Quote
Administrators PlausiblyDamp Posted February 15, 2005 Administrators Posted February 15, 2005 You would need to use some other method - either a java applet to perform the work or possibly implement the file upload as a web service and provide a wndows based client to do the work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rfazendeiro Posted February 15, 2005 Author Posted February 15, 2005 actually a solved the problem! i can browse througth directories and get the files that existe currenttly there. And i can event open the file if i want. you you want the solution just let me know and i'll post it here Quote
adamsinline Posted February 21, 2005 Posted February 21, 2005 I would like the solution. Thanks Quote
rfazendeiro Posted February 22, 2005 Author Posted February 22, 2005 well...it's quite simple. Bare in mind that this browses througth the server's hard disk not the client's here it is :) Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Browse() End Sub In this sub "ServerDirectory" is a constant from where tou want to start. you can get all drives with drives = System.IO.Directory.GetLogicalDrives() Private Sub Browse() Try Dim dir As DirectoryInfo = New DirectoryInfo(ServerDirectory) Dim fsi As FileSystemInfo For Each fsi In dir.GetFileSystemInfos() Try 'This means it is'nt a file thus a directory If Not TypeOf fsi Is FileInfo Then Dim d As DirectoryInfo = CType(fsi, DirectoryInfo) Dim dirName As String = Path.GetFullPath(d.FullName.ToString) response.write("dirName") If (d.GetDirectories().Length > 0) Then LoadSubDirectory(dirName) Else response.write("dirName") End If End If Catch Ex As Exception End Try Next fsi Catch Ex As Exception Response.Write(Ex.ToString()) Response.End() End Try End Sub then recursevly i get all subdirectories Private Sub LoadSubDirectory(ByVal thisDir, ByVal contadorPai, ByRef _menuHtml) Try Dim dir As DirectoryInfo = New DirectoryInfo(thisDir) Dim fsi As FileSystemInfo For Each fsi In dir.GetFileSystemInfos() Try If Not TypeOf fsi Is FileInfo Then Dim d As DirectoryInfo = CType(fsi, DirectoryInfo) Dim dirName As String = Path.GetFullPath response.write(dirName) If (d.GetDirectories().Length > 0) Then LoadSubDirectory(dirName, strMenuNome, _menuHtml) End If End If Catch E As Exception End Try Next fsi Catch E As Exception Response.Write(E.ToString()) Response.End() End Try End Sub hope it helped :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.