gioma 19 Posted November 26 Hi, I need to retrieve information about a file, to do so I use the FindFirst function. The problem is when I use it with a network file it returns error 2: The system cannot find the file specified. //FileName='\\SERVER-CODE\DelphiShared\Test.txt' //FileName='\\192.168.0.100\DelphiShared\Test.txt' procedure PrepareToTransferLocalFiles(FileName:string); begin if FindFirst(FileName, faAnyFile, sr) = 0 then begin //some code.. else begin WriteLog('[PrepareToTransferLocalFiles] Open File ' + FileName + ' Err: '+intToStr(GetLastError)+' : '+SysErrorMessage(GetLastError)+')' ); end; FindClose(sr); //some code.. end; where am I going wrong? PS The program uses a browser component that uses network authentication when it needs to access protected folders. Share this post Link to post
PeterBelow 238 Posted November 26 You need file system level authentification to access files on the LAN via file system API functions, see WNetAddConnection3 if this is for Windows. For web folders you have to use something like ftp if the server supports it. Share this post Link to post
gioma 19 Posted November 27 23 hours ago, PeterBelow said: You need file system level authentification to access files on the LAN via file system API functions, see WNetAddConnection3 if this is for Windows. For web folders you have to use something like ftp if the server supports it. thanks for the reply. Yes, what you say is already done by the browser component, the problem is another, for network paths I always have to add the prefix "\\?\UNC\" otherwise it doesn't work. Share this post Link to post
DelphiUdIT 178 Posted November 27 (edited) For a long time I have always used the form "\\?\". It has some advantages (like bypass MAX_PATH limits and the name parsing). See here: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#win32-file-namespaces Bye Edited November 27 by DelphiUdIT 1 Share this post Link to post