Page 1 of 1

[CLOSED] WINDOWS: CopyFile() limit?

Posted: Mon Oct 28, 2024 4:39 pm
by TI-994A
While trying to copy a bunch of files, each with a combined path name of about 100 characters long, only the first 265 copy operations succeed, while the rest will fail.

At first I thought that the paths of the failed copy operations could be corrupted, but I tried to run them separately and they worked.

Here's a pseudocode of the routine:

Code: Select all

fileName.s = "SOME_REALLY_LONG_FILENAME_WITH_DATES_AND_CODES_AND_STUFF.txt"

OpenFile(0, foldersFile.s)

While Not Eof(0)
  
  pathName.s = ReadString(0)   ; the destination folder name
  
  fName = ; the original fileName modified with different dates and codes
          
  If CopyFile(GetCurrentDirectory() +  "\sample.txt", pathName + fName)

    Debug "sample.txt > copied to > " + pathName + fName
        
  EndIf  
   
Wend

CloseFile(0)
The paths and file names are all valid because the copy operations work if only 265 of them are performed at one go.

Anyone have any idea why the 265 limit?

Re: WINDOWS: CopyFile() limit?

Posted: Mon Oct 28, 2024 5:08 pm
by Kiffi
That could have something to do with this: Maximum Path Length Limitation

Re: WINDOWS: CopyFile() limit?

Posted: Mon Oct 28, 2024 5:44 pm
by TI-994A
Kiffi wrote: Mon Oct 28, 2024 5:08 pm That could have something to do with this: Maximum Path Length Limitation
Hi Kiffi. I thought that too, at first. But all the copy operations with the existing full-length paths and file names work without issue.

It only fails if an attempt is made to perform more than 265 CopyFile() operation in a single go. :?

Re: WINDOWS: CopyFile() limit?

Posted: Mon Oct 28, 2024 6:13 pm
by TI-994A
Sorry everyone! Please disregard the question.

The copy operations depended on some input files, but I didn't realise that there were only 265 of them. And thus the failure. :oops:

Thank you to everyone who had spent any time investigating this. Much appreciated. :D