Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Location file in the network
Message
De
16/02/2004 04:30:22
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
16/02/2004 02:34:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00877551
Message ID:
00877565
Vues:
13
>hi all
>
>How to get the network address + the location of the filename ?
>
>Something like getfile(), getfile() return 'c:\text.txt'
>
>but i would like to have the network name included
>
>\\servername\sharefolder\text.txt
>
>Thanks in advance

GetFile() returns the fullpath (either c:\path\filename or \\servername\sharedfolder\filename). If you mean to return UNCpAth from a mapped drive this might help :
#Define ERROR_NOT_CONNECTED 2250
#Define ERROR_MORE_DATA 234
#Define ERROR_BAD_DEVICE 1200
#Define ERROR_CONNECTION_UNAVAIL  1201
#Define ERROR_NO_NETWORK 1222
#Define ERROR_NO_NET_OR_BAD_PATH 1203
#Define ERROR_EXTENDED_ERROR 1208

#Define UNIVERSAL_NAME_INFO_LEVEL   0x00000001
#Define REMOTE_NAME_INFO_LEVEL      0x00000002
Declare integer WNetGetUniversalName in win32API ;
  string @ lpLocalPath, ;
  integer dwInfoLevel,  ;
  string @ lpBuffer,  ;
  integer @ lpBufferSize

Declare integer GetLongPathName in win32API ;
  string @ lpszShortPath, string @ lpszLongPath, integer cchBuffer

lpLocalPath = GetFile()

lpBufsize = 512
Store space(512) to lpBuffer,lpszLongPath
lnResult = WNetGetUniversalName(@lpLocalPath,REMOTE_NAME_INFO_LEVEL ,@lpBuffer,@lpBufsize)
If lnResult = ERROR_MORE_DATA && Buffer was small -retry with new bufsize
  lnResult = WNetGetUniversalName(@lpLocalPath,REMOTE_NAME_INFO_LEVEL ,@lpBuffer,@lpBufsize)
ENDIF
? lnResult
Do case
  Case lnResult=0
    lcInfo =  substr(lpBuffer,13)
    Alines(arrInfo,chrtran( substr( lcInfo,1,at(chr(0),lcInfo,3) ),chr(0),chr(13)))
    ? 'Full UNC path : '+arrInfo[1]
    ? 'Server path   : '+arrInfo[2]
    ? 'File Path     : '+arrInfo[3]
    ? lpLocalPath
  Otherwise && Assume local path
    ? lnResult
    lnBuf = GetLongPathName(@lpLocalPath, @lpszLongPath, lpBufsize)
    ? substr(lpszLongPath,1,lnBuf)
Endcase
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform