The problem is that the new File()
Groovy/Java code is running on the Jenkins server and looking on the filesystem there, but the file you want to look at is on the machine that the Jenkins agent is running on. All the Groovy/Java code runs on the server and whenever you call a Jenkins pipeline step the server tells the agent to perform it locally and return the result. So to find the size of a file you'll need to use the findFiles()
pipeline step and look at the result of that (see https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#findfiles-find-files-in-the-workspace).