Jump to content
gioma

FindFirst : with network files it fails

Recommended Posts

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

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×