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 181299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:44:20+00:00 2026-05-11T14:44:20+00:00

Good morning, is there a way to get a DriveInfo instance for UNC paths

  • 0

Good morning,

is there a way to get a DriveInfo instance for UNC paths (e.g. ‘\fors343a.ww123.somedomain.net\folder\1\’) because for example…

var driveInfo = new System.IO.DriveInfo(drive); 

… throws an ArgumentException (‘Object must be a root directory (\’C:\\’) or a drive letter (\’C\’).’) when using that UNC path above.

What would I use in order to retrieve information about that or e.g. how would I check whether a given folder resides on a local drive or an unc path?

  • 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. 2026-05-11T14:44:21+00:00Added an answer on May 11, 2026 at 2:44 pm

    The Remarks section for the DriveInfo constructor says:

    The drive name must be either an uppercase or lowercase letter from ‘a’ to ‘z’. You cannot use this method to obtain information on drive names that are nullNothingnullptra null reference (Nothing in Visual Basic) or use UNC (\server\share) paths.

    I was able to make it work by mapping a network drive in Windows Explorer. That is, I mapped ‘\server\share’ to drive Z, and then DriveInfo('Z:\\'); gave me what I expected.

    Unfortunately, there’s no simple way to map a network drive from C#. You’ll either have to execute an external command (i.e. ‘net use z: \server\share’), or call the Windows WNetAddConnection2 API function to do it. Either way you go, you’ll need to remove the drive mapping when you’re done.

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

Sidebar

Related Questions

Possible Duplicate: (C#) Get index of current foreach iteration Good morning, Is there any
Good morning, is there any way to exclude only one particular directory from a
Good morning is there a clever way to use a javascript regular expression to
Good morning guys Is there a good way to use regular expression in C#
Good morning, Does anyone know if there is an easy way I can use
Good morning all. Is there any jsf control that escapes the html tags? Imagine
Good morning ! What is the best way to remove duplicate records from grid
Good morning all. I've been pondering over the best way to use plupload with
Good Morning, I was looking for a way to combine two integers to create
Good morning. I realize there are a ton of questions out there regarding replace

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.