Sign in to follow this  
Followers 0
Lee Evans

-Splitpath and UNC paths

4 posts in this topic

Pardon my ignorance but I wondered if the splitpath UDF returns the correct value for the drive section using the attached as an example

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFName, $szExt
$TestPath = _PathSplit("\\Lee\Drive-c\dev\version\file.txt", $szDrive, $szDir, $szFName, $szExt)
_ArrayDisplay($TestPath,"Demo _PathSplit()")

This gives a return of

[0] = \\Lee\Drive-c\dev\version\file.txt = Full path

[1] = \\Lee = Drive

[2] = \Drive-c\dev\version\ = Directory

[3] = file = filename

[4] = .txt = File extension

But is the drive in this case really just \\Lee isn't it \\Lee\Drive-c?

Sorry I am new to UNC paths and any enlightment would be greatly received. I am scripting an application which has just added UNC path support and need to update some of my scripts and just wanted to get my head around the UNC paths that I might encounter.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Pardon my ignorance but I wondered if the splitpath UDF returns the correct value for the drive section using the attached as an example

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFName, $szExt
$TestPath = _PathSplit("\\Lee\Drive-c\dev\version\file.txt", $szDrive, $szDir, $szFName, $szExt)
_ArrayDisplay($TestPath,"Demo _PathSplit()")

This gives a return of

[0] = \\Lee\Drive-c\dev\version\file.txt = Full path

[1] = \\Lee = Drive

[2] = \Drive-c\dev\version\ = Directory

[3] = file = filename

[4] = .txt = File extension

But is the drive in this case really just \\Lee isn't it \\Lee\Drive-c?

Sorry I am new to UNC paths and any enlightment would be greatly received. I am scripting an application which has just added UNC path support and need to update some of my scripts and just wanted to get my head around the UNC paths that I might encounter.

Yes it gives the correct value. \\Lee is the name of the computer that is being accessed. Essentially accessing it is similar to accessing a drive. It wouldn't be \\Lee\Drive-c because the Drive-c folder, though it may be a drive on the computer you are accessing, is not a drive of the current computer itself. As a result it appears as a subfolder of the remote \\Lee computer because to the computer that you are currently running, the remote lee computer is like a drive. The actual physical drives of the remote lee computer therefore don't have any merit to the computer that is accessing the remote computer or its drives and the drives of the remote computer simply appear as subfolders.

I hope that made sense.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

easiest way i did it in a script was if beginning of path = "\\" then drivemapadd

do yer stuff, then drivemapdelete what you created

for example.......

if Stringleft($TestPath2) = "\\" then $Path=DriveMapAdd("*:", $Path) ; creates a driveletter

do yer stuff then

if Stringleft($TestPath2) = "\\" then DriveMapDel($Path); to remove it

hope that helps , its all in the help

Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

Thanks for the above they both helped

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0