Page 1 of 2
FileSize says file does not exist
Posted: Wed Mar 05, 2014 12:44 pm
by PB
Same result when run as limited or with admin rights.
Code: Select all
Debug FileSize("C:\Windows\System32\mblctr.exe") ; -1

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:19 pm
by Thunder93
That file doesn't exists in \SysWoW64. Try with the x64 PB Compiler, it should work okay then.
Using 32Bit App, to see 64bit system32, use instead
Debug FileSize("C:\Windows\
sysnative\mblctr.exe")
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:21 pm
by Little John
Issue confirmed here on Windows 7 x64 with PB 5.21 LTS x86.
The code works here correctly though with PB 5.21 LTS x64.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:23 pm
by Thunder93
Not a bug really.

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:28 pm
by ts-soft
No Bug, only virtualisation
Code: Select all
Define.s File = "C:\Windows\System32\mblctr.exe"
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
File = "c:\Windows\Sysnative\mblctr.exe"
CompilerEndIf
Debug FileSize(File)
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:32 pm
by PB
> CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
But that produces an exe for only one processor type. Do
I have to compile two versions of my app from now on?
And it's not a good enough solution, anyway, because that's
just ONE file. Does my app have to conditionally compile a
whole folder of Windows files to ensure they look right on
any given PC? It's a horrible way to "fix" the problem.
And when my users start saying "what's this SysNative all
about", I then have support issues where I have to explain
that what they see in the "Properties" box isn't true at all.
Ah, damn I hate Windows sometimes. Don't know why I'm
still coding for it. POS operating system.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:37 pm
by ts-soft
If your 32-Bit program run on a 64-Bit OS, you have to use sysnative dir, it is the same with some registry keys.
The redirection is a windows feature

, not a PB Bug
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:38 pm
by PB
As a possible solution, is it safe to just search/replace the
"System32" part of the string with "SysNative" if FileSize()
returns -1, then? Seems a lot simpler and the user won't
know it was done that way to present the correct size.
Like this:
Code: Select all
f$="C:\Windows\System32\mblctr.exe"
s=FileSize(f$)
If s=-1
s=FileSize(ReplaceString(f$,"\System32\","\SysNative\"))
EndIf
Debug s
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:40 pm
by ts-soft
Check if the sysnative dir exists, if exist, use it!
On a 32-Bit OS you wouldn't found this dir.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 1:44 pm
by PB
> Check if the sysnative dir exists, if exist, use it!
Not that simple. It doesn't "exist" on my 64-bit Windows.
Can't view it in Explorer or with the "dir" DOS command.
And yes, I'm viewing all files/folders/nothing hidden/etc.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:09 pm
by Thunder93
It's a pseudo directory for 32App on 64bit OS, using Filesize and determining if the folder exists won't work. Use one of many ways already mentioned on the forums.
PB wrote:> Check if the sysnative dir exists, if exist, use it!
Not that simple. It doesn't "exist" on my 64-bit Windows.
Can't view it in Explorer or with the "dir" DOS command.
And yes, I'm viewing all files/folders/nothing hidden/etc.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:15 pm
by ts-soft
Use a 32-Bit FileManager (Total Commander recommend).
Windows-Explorer is bad for none DAUs

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:36 pm
by Thunder93
Filesize() is used heavily in some projects. Having said that, .. speed is important. This extra stage would be undesired.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:37 pm
by PB
> speed is important. This extra stage would be undesired.
I know! That's why it sucks to have to do the check.

But if you DON'T check, then you're going to have bugs,
just as I showed in my first post. You can't trust FileSize.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:41 pm
by Thunder93
What's your case scenario for your project? Code be different based on your needs. Is it important for your 32App to see 64bit versions of files?