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

Posted on 2007-07-22
Last Modified: 2007-07-22
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?
Question by:bemara57
    LVL 19

    Accepted Solution

    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.

    Author Comment

    I didn't know Parent.FullName existed.. that's exactly what I needed. Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now