• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

How do I get fullname of parent Directory in ASP.NET 2.0 / C#?

I'm trying to get the full path of the parent directory using Sytem.IO's built in .Parent function, but they only return the name of the parent directory, not the full name. So I get this:

FullName                   Name            Parent
----------------------------------------------------
C:\Temp\First             First             Temp
C:\Temp\Second       Second        Temp
C:\Temp\Third            Third            Temp

I really want to make the parent field C:\Temp. So I was thinking to remove the name from the fullname, then prefix to the parent name. What's the best way to do this?
0
bemara57
Asked:
bemara57
1 Solution
 
drichardsCommented:
Which Parent are you referring to?

On DirectoryInfo, you can do .Parent.FullName to get the complete path.  .Parent.Name just gives you the folder name.
0
 
bemara57Author Commented:
I didn't know Parent.FullName existed.. that's exactly what I needed. Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now