Forum Discussion

malj's avatar
malj
Contributor
11 years ago

Saving Picture to File with Spaces in File Name

I am having trouble saving a screenshot with spaces in the file name (in strIDAndType below, taken from a property of an on-screen object in Chrome).



strFileName = "C:\CoverityIssues\" & strIDAndType & ".png"

Sys
.Desktop.Picture.SaveToFile(strFileName)



I have tried creating the file name like this but it does not help:



strFileName = """C:\CoverityIssues\" & strIDAndType & ".png"""



Any ideas?  





  




 


4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Magnus,



    Just a quick check:

    Might it be that strIDAndType variable contains characters that are not allowed in the file names?



    Sys.Desktop.Picture.SaveToFile("c:\a a.png")

    worked fine for me.
  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor
    Try this out (i believe your problem happens because you're using only one slash)



    Path = "C:\\folder\\subfolder\\auto tests\\";



    Another useful function I found out is this:



     // function that executes path that contains space chars

    var objShell = new ActiveXObject("shell.application");        

    objShell.ShellExecute(ficheiro, "", "Path", "open", 1);
  • malj's avatar
    malj
    Contributor
    Not sure what caused this but I have never had to use \\ in paths that I can remember. I ended up creating the screenshot file name from strings taken from different on-screen objects instead.

    Thanks anyway!
  • When the image that gets imported has spaces in the file name they get imported and saved as HTML encoded characters. So a file that is: "imported file.png" will be saved as "imported%20file.png".



    This will generally be ok on linux systems but in windows systems (IIS at least, not sure about apache), later use of the image will not work properly.



    It should be saved as it originally was and maybe even have an option to allow the admin to replace spaces with dashes or something.