How to list PDF page sizes in the command line

In the Ghostscript documentation I did not found arguments to query the paper sizes of a PDF document. I read about a pdf_info.ps file in the lib subdirectory. I tried this code:

private const string RutaAGhostscript = @"C:\Program Files\gs\gs9.52\bin\gswin64c.exe"; . Process pTamaños = new Process(); pTamaños.StartInfo.FileName = RutaAGhostscript; pTamaños.StartInfo.Arguments = " -dNODISPLAY -q -sFile=\"" + RutaSeleccionada + "\" -DumpMediaSizes \"C:\\Program Files\\gs\\gs9.52\\lib\\pdf_info.ps\""; pTamaños.StartInfo.UseShellExecute = false; pTamaños.StartInfo.RedirectStandardOutput = true; pTamaños.Start(); EscribirArchivo(pTamaños.StandardOutput.ReadToEnd(), RutaResultadoTxt2); pTamaños.WaitForExit(); 
I got this output in the result file:
Error: /invalidfileaccess in --file-- Operand stack: (C:\\Users\\claudio.bogado\\QGMI\\Ruben De Jes\303\272s Martinez - 2020-05 Certificado 16\\Tramo 3\\Certificado 16 Tramo 3.pdf) (r) Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- Dictionary stack: --dict:739/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)-- --dict:15/128(L)-- Current allocation mode is local Last OS error: Permission denied Current file position is 11770 

Using the xPDF tools I tryed pdfinfo -box and some files with different page sizes only shows the first page. Am I imputing wrong the file name? UPDATE: I tried using GetShortPathName of kernel32 to get rid of the spaces. The only difference in the error output was the name of the file that now is C:\\Users\\CLAUDI~1.BOG\\QGMI\\RUBEND~1\\TRAMO3~1\\CERTIF~1.PDF Also tried changing the backslash for the slash and the difference is the error message now shows C:/Users/CLAUDI~1.BOG/QGMI/RUBEND~1/TRAMO3~1/CERTIF~1.PDF Greetings from Paraguay. Claudio Bogado Pompa.