Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:27:13+00:00 2026-06-16T04:27:13+00:00

For example, string path = @C:\User\Desktop\Drop\images\; I need to get only @C:\User\Desktop\Drop\ Is there

  • 0

For example,

string path = @"C:\User\Desktop\Drop\images\";

I need to get only @"C:\User\Desktop\Drop\

Is there any easy way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:27:14+00:00Added an answer on June 16, 2026 at 4:27 am

    You can use the Path and Directory classes:

    DirectoryInfo parentDir = Directory.GetParent(Path.GetDirectoryName(path));
    string parent = parentDir.FullName; 
    

    Note that you would get a different result if the path doesn’t end with the directory-separator char \. Then images would be understood as filename and not as directory.

    You can also use a subsequent call of Path.GetDirectoryName

    string parent = Path.GetDirectoryName(Path.GetDirectoryName(path));
    

    This behaviour is documented here:

    Because the returned path does not include the DirectorySeparatorChar
    or AltDirectorySeparatorChar, passing the returned path back into the
    GetDirectoryName method will result in the truncation of one folder
    level per subsequent call on the result string.
    For example, passing
    the path “C:\Directory\SubDirectory\test.txt” into the
    GetDirectoryName method will return “C:\Directory\SubDirectory”.
    Passing that string, “C:\Directory\SubDirectory”, into
    GetDirectoryName will result in “C:\Directory”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An example string: AB-XYZ-123 Where: AB : Any two capital alphabets only, no symbol,
I have an example string as follows $string = ' http://image.gsfc.nasa.gov/image/image_launch_a5.jpg http://pierre.chachatelier.fr/programmation/images/mozodojo-original-image.jpg http://image.gsfc.nasa.gov/image/image_launch_a5.jpg Alot
What is the best way to parse time from a string? Example string: this
I have here a string(an input from the user) for a file path. I
I need to develop a template-like user control, which would accept any arbitrary content,
I have a string.An example is given below. [playlist]\r\npath1=url1\r\npath2=url2\r\npath=url3\r\npath4=url4\r\ncount=1 How can I extract path
Example string $string = 'how-do-i-retrieve-last-word' $string = 'how-do-i-retrieve-last-word-2' $string = 'how-do-i retrieve-last word-123' $string
For example: string element = 'a'; IEnumerable<string> list = new List<string>{ 'b', 'c', 'd'
For example: string = This is a link http://www.google.com How could I extract 'http://www.google.com'
I am trying an example: String hashAlgorithm =sha-256 ... md=MessageDigest.getInstance(hashAlgorithm); byte[] enteredPasswordDigest = md.digest(policy.getPassword().getBytes());

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.