Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Get the Drive Component of a UNC

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

Is there any functions that can return only the drive component from a unc string. It needs to include the machine name as well, such as \\machine\share$

Using VFP9...

Thanks, Stanley
 
There is a third even worse case with quotas: You only have a quoata in a certain subfolder of a share, eg your user/home folder, then determining the "drive" or root share may result in 0 available space, while you have sufficient space in that home folder.

Overall: Everything speaks for determining the space of the path you want to save in, nothing speaks for first determining the share root folder or "drive".

Bye, Olaf.
 
Quotas limit space in a drive in the same way as a shelf of a cupboard assigned to you limits your space inside the cupboard and the cupboard limits space for cupboard storable thingys in the space of the whole room, though the room or cupboard still may have space, when your shelf is full.

If you want to put a book into a certain shelf, you don't ask for space available in the cupboard, the room, the flat, the house, the street, city, county, state, country, continent, world, solar system, galaxy or the universe, YOU ASK FOR THE SPACE LEFT IN THAT SHELF AND NOTHING ELSE!

Is that clear?

Bye, Olaf.
 
>However, considering what strongm mentions about quotas, then I should shorten the unc????

No, I was merely pointing out that Olaf's examples of

1. FSO.GetDrive("T").AvailableSpace
2. DISKSPACE("T")
3. DISKSPACE("\\server\share")
4. DISKSPACE("\\server\share\folder")

do not always necessarily get the same results.

However as he has eloquently and repeatedly tried to explain, trying to find the available capacity of a particular share/folder is not achieved by trying to find out the available capacity of the hosting root drive/volume - which is what you seem to be trying to do.
 
Stanlyn,

as you said:
Stanlyn said:
I'm testing if the drive that hosts a particular table has enough free disk space.

All you need to ask is, IF DISKSPACE(somepath)>neededbytes, there is no need to determine any root path.

You might get -1 from DISKSPACE in several cases, but mainly if the server serving the share is offline or even powered off. If the share is connected via VPN also, when there currently is no VPN connection. Anyway, if you want error tolerance of some level, you could do

Code:
lnDiskspace = DISKSPACE(somepath)
Do Case
   Case lnDiskspace<0
        Messagebox("Sorry. Currently the size of "+somepath+" could not be determined.")
        Return
   Case lnDiskspace < neededbytes
        Messagebox("insufficient available space on "+somepath)
        Return
   Otherwise
        Messagebox("Available space is fine")
EndCase
* Continue here

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top