Link to home
Start Free TrialLog in
Avatar of Howard Bash
Howard BashFlag for United States of America

asked on

UNC Information from VB.NET

How can I obtain disk information (total size, free,  etc...) given the UNC for a network share using VB.NET?

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Howard Bash

ASKER

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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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