Solved

Path.GetDirectoryName

Posted on 2006-07-23
10
680 Views
Last Modified: 2011-09-20
I would like to get a folder name instead of a file name and display it in the text box.
I am using this code in the ASP.NET webform but it's good only for a file name not folder name.

 Dim infolder As String
       infolder = Path.GetDirectoryName(infolder)
        txtBox.Text = infolder


Thanks
0
Comment
Question by:jskfan
  • 6
  • 4
10 Comments
 
LVL 12

Accepted Solution

by:
TheMegaLoser earned 450 total points
ID: 17164560
For Path.GetDirectoryName to recognize a folder correctly you need to end the string with a \

To get around this you can do the following:

        Dim infolder As String
        If System.IO.Directory.Exists(infolder) Then
            txtBox.Text = infolder
        Else
            txtBox.Text = System.IO.Path.GetDirectoryName(infolder)
        End If

Documentation can be found @:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiopathclassgetdirectorynametopic.asp
http://blogs.msdn.com/bclteam/archive/2004/11/16/258658.aspx
0
 

Author Comment

by:jskfan
ID: 17171210
I used the code above, but it still doesn't pick a folder when I select it on the open dialogbox, it works only for a file.
0
 
LVL 12

Expert Comment

by:TheMegaLoser
ID: 17173894
Exactly whats the string (directory) that you're trying to check?

And what do you mean with the open dialogbox in webforms? Are you talking about the file upload control or am I missing something here?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:jskfan
ID: 17177090
when you click the browse button it opens a dialog box and you can browse through drives and pickup a filename then click open and the filename with the path will showup in the textbox.
BUT what I want is instead of pickingup a filename I will be able to pickup a foldername and the foldername will showup in the textbox with the path.
0
 

Author Comment

by:jskfan
ID: 17192714
any update?
0
 
LVL 12

Expert Comment

by:TheMegaLoser
ID: 17208723
Sorry, been away for a couple of days.

I have to admit I'm a bit confused as to what you want to do. If I understand you correctly you're using the asp:fileupload control? The file upload (or INPUT TYPE=FILE as it's based on) will always upload a file. You can't change the filename of the file in the client from the server.

Even if you could the browser still wouldn't upload the entire directory you're pointing at to the server.

I'm pretty sure I've misunderstood something, can you please shed some more light? Part of the ASPX page perhaps?
0
 

Author Comment

by:jskfan
ID: 17218189
let me make it simple.

I have a textbox on ASP web page, I want a user to click the browse button and select any folder in the network and make that folder shows up on the texbox of the web page.

Because later when the user sends that web page to the administrator, the admin will give him permissions on the folder that the user selected and shown on the web page textbox.
0
 
LVL 12

Expert Comment

by:TheMegaLoser
ID: 17221648
Is the folder on the server or on the users computer?
0
 

Author Comment

by:jskfan
ID: 17227759
the folder is on the server in the network.
0
 

Author Comment

by:jskfan
ID: 17278633
any update?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
daypilot scheduler 3 30
Gridview selected row 9 47
ASP.net VB.net Errors when sending data to SQL 5 20
Linq asp.net mvc 13 12
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question