Fix for #23700 Non-deterministic static files test failures on Windows

PermissionError: [WinError 5] Access possibly raised when write
permission on the parent directory is not there. In any case
a permission check there would help. We might want to assert false
when there is no permission to create the folder. Haven't added it
in case it is handled elsewhere.