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

  • Home
  • SEARCH
  • 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

Good morning, I've got an ASP.NET MVC VB2008 .NET 3.5 project I'm upgrading to
Good morning, afternoon or night, Foreword: The code below does nothing really useful. It
Good morning, Where can I declare static libraries in Eclipse. I have some *.lib
Good morning everbody, I'm trying to pass a UiBinder from a rpc-service to the
Good morning, I´m facing a very strange problem on which I haven´t found a
Good morning, I want to create a Google Maps overlay from GeoTiff data I
Good morning! I'm writing a class for drawing histograms and, for user's convenience, I've
Good morning All, I have a javascript variable in my view. I keep doing
What is the best method to cache the following? I am creating an intranet
I'm at the moment trying to make a very simple app that will greet

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.