Solved

Path.GetDirectoryName

Posted on 2006-07-23
10
671 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
varchar (max) 5 28
What is MicroStrategy.NET? 2 45
Mutually exclusive checkbox in a gridview 18 41
Paging GridView 7 34
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now