[python-win32] detect mapped network path
Simon Dahlbacka
simon.dahlbacka at gmail.com
Fri Jul 1 08:21:23 CEST 2005
On 7/1/05, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local
> > path or in fact a mapped network path?
>
> win32api.GetLogicalDriveStrings() may also help.
I was going to say that it does not help, but then I found
win32file.GetDriveType
so for future reference, here is a solution that WorksForMe(tm)
>>> def IsMappedDrive(name):
... allDrives = win32api.GetLogicalDriveStrings().split("\x00")
... return name.upper() in [drive for drive in allDrives if
win32file.GetDriveType(drive) == win32file.DRIVE_REMOTE]
>>> IsMappedDrive("z:\\")
True
>>> IsMappedDrive("c:\\")
False
..so thanks for the pointer
/Simon
More information about the Python-win32
mailing list