For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > April 2006 > chooseDirectory and UNC path









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author chooseDirectory and UNC path
s.berndt@bk-cad.de

2006-04-05, 7:59 am

Hi Folks,

i have a problem using "chooseDirectory" on WIN32. Anything works fine
setting any local directory as "-initialdir". But trying to use a
remote directory like
....
my $buf = $mainWindow->chooseDirectory(
-title => "Select directory",
-initialdir => "//remoteHost/smbshare/",
-mustexist => "true");
....

leads to a windows error message, because chooseDirectory tries to
access the first host visible in the network environment (which is not
the machine providing "initialdir" and the access to this machine is
not allowed). After confirming the error message the directory
selection opens with the standard network environment as root path.
I've tried any imaginable combination of "/" and "\" to adress the
path, but the result is always the same.

Any idea?

QoS@domain.invalid.com

2006-04-05, 7:01 pm


"s.berndt@bk-cad.de" <s.berndt@bk-cad.de> wrote in message-id:
<1144229772.031535.323970@g10g2000cwb.googlegroups.com>
>
>Hi Folks,
>
>i have a problem using "chooseDirectory" on WIN32. Anything works fine
>setting any local directory as "-initialdir". But trying to use a
>remote directory like
>...
>my $buf = $mainWindow->chooseDirectory(
> -title => "Select directory",
> -initialdir => "//remoteHost/smbshare/",
>-mustexist => "true");
>...
>
>leads to a windows error message, because chooseDirectory tries to
>access the first host visible in the network environment (which is not


not 100% sure what you mean by visible.. assuming master browser list.

>the machine providing "initialdir" and the access to this machine is
>not allowed). After confirming the error message the directory
>selection opens with the standard network environment as root path.
>I've tried any imaginable combination of "/" and "\" to adress the
>path, but the result is always the same.
>
>Any idea?


Try using the IP address rather than the Computer name?

eg: -initialdir => "//10.20.30.40/smbshare/"



s.berndt@bk-cad.de

2006-04-06, 8:00 am

> not 100% sure what you mean by visible.. assuming master browser list.

yes, sorry, only have a german desktop available ... tried with a
translation "word by word"

> Try using the IP address rather than the Computer name?


good idea (!), but unfortunately the result is the same.

any more ideas?

s.berndt@bk-cad.de

2006-04-06, 8:00 am

> Regarding the / or \ problem, Windows help seems to say that
\\host\path\to\file is correct.

yes, it is. The question was, if this may be a specific problem with a
UNC-Path, because "chooseDirectory" normally translates "/" "\" itself
and it works independent from which separator you are using in code
(and "/" is much better, it prevents you code from this ugly
"\\\\host\\path\\to\\file" expressions ;-))

> Try mapping the remote directly as an unused local drive letter.


could be a solution, but would confuse our users :-(

If there is no other solution, it would be of interest WHY it doesn't
work. If i type "\\host\path\to\file" into the adress entry of the
windows explorer, it works correct. Could it be a problem of the Win32
API ???

QoS@domain.invalid.com

2006-04-07, 7:00 pm


"s.berndt@bk-cad.de" <s.berndt@bk-cad.de> wrote in message-id:
<1144325446.787147.311630@g10g2000cwb.googlegroups.com>
>
>\\host\path\to\file is correct.
>
>yes, it is. The question was, if this may be a specific problem with a
>UNC-Path, because "chooseDirectory" normally translates "/" "\" itself
>and it works independent from which separator you are using in code
>(and "/" is much better, it prevents you code from this ugly
>"\\\\host\\path\\to\\file" expressions ;-))
>
>
>could be a solution, but would confuse our users :-(


Hmm, perhaps you could include a NET USE statement to map the
drive prior to calling -initialdir

eg NET USE s: \\file_service_PC\shared_folder

Then unmap the mapped drive after the code is done using it.

eg NET USE s: /DELETE

NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

>If there is no other solution, it would be of interest WHY it doesn't
>work. If i type "\\host\path\to\file" into the adress entry of the
>windows explorer, it works correct. Could it be a problem of the Win32
>API ???


Nod, it is interesting.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com