We help IT Professionals succeed at work.

UNC Information from VB.NET

2,032 Views
Last Modified: 2013-11-26
How can I obtain disk information (total size, free,  etc...) given the UNC for a network share using VB.NET?

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Howard BashSenior Software Engineer

Author

Commented:
The above code I think will iterate all the drives that are mapped on my PC,  however the problem is that I have many many shares to retrieve this information from and I do not want to map all the shares.  

What I need is a function that will accept a UNC such as \\SomeSharedServer\C$ and return total size, free space, etc.
i don't know if this code will work on a share with the C$ at the end but the code i gave above could be used like this
Dim drive As System.IO.DriveInfo = My.Computer.FileSystem.GetDriveInfo("\\SomeSharedServer\C$")
dim freeSpace as long = drive.AvailableFreeSpace
the problom is that drives found by that method usaly reqiure a password to access. i have don't know how visual basic will handle this. but try that code  if you get access this way you can read and even write files on that drive not just rad free space. i hope this helps.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Howard BashSenior Software Engineer

Author

Commented:
I saw that you can get the information by letter and that implied that I might be able to get such information if I mapped the UNC path and then passed the letter.  For some reason,  there appears to be no way to go directly and get the info from the UNC.

I wrote a routine to map and unmap shares, but as you noted, VB Student,  I need rights to the shares (uid/pwd) and would need to use these to grant rights to execute the function upon.  It works,  but that I need to map/unmap to obtain a set of paths seems like a waste of bandwidth.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Howard BashSenior Software Engineer

Author

Commented:
I'd like to hang in on the question for another day or so and see if anyone else has another avenue to check.
No you misunderstood.
The letter you assign is a temporary drive letter assigned by the program .
Here is the way it works.
You input a UNC path.The code creates a map with a temporary letter,gets the information of that drive and then disconnects it.So you dont have to map the drive before you run the program

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.