scan WIN directories with UNC pathnames

Peter Hansen peter at engcorp.com
Mon Jul 26 09:19:50 EDT 2004


Thomas Rademacher wrote:
> Hallo,
> 
> my application want to scan WIN directories with UNC pathnames.
> 
> The methods os.path.isdir(pathname) and os.listdir(pathname) work fine with
> pathname="\\\\servername\\path".
> But with the argument pathname="\\\\servername" the method
> os.path.isdir(pathname) returns 0 and the method os.listdir(pathname) raises
> an exception.
> 
> What is the reason? And how can I scan such UNC directories
> (pathname="\\\\servername")?

What Tim said.... and as further clarification, what you show above
as \\servername\path is not valid.  It's actually \\servername\share,
where the "\share" part effectively represents the root directory
of the shared folder.  Think of it as being no different than "C:\".

Note that if you do "dir \\servername" at a DOS prompt, you'll get
the same sort of errors as what you got above:

   "The filename, directory name, or volume label syntax is incorrect."

-Peter



More information about the Python-list mailing list