in my ruby-code I want to save some contents in a file. This file should be saved at a directory with whitespace in its path.
If the directory doesn't exist I do: Dir.mkdir(directory_name) unless File.exists?(directory_name)
This works in a directory without whitespace in path.
I put the filepath in "" and in '' but then the following error occured:
C:/Program Files (x86)/MantisScraper/mantis_final.rb:378:in `initialize': Invalid argument - "C:\Program Files (x86)\MantisScraper\testfiles\"test_cases_5_5_0.xml (Errno::EINVAL)
from C:/Program Files (x86)/MantisScraper/mantis_final.rb:378:in `new'
from C:/Program Files (x86)/MantisScraper/mantis_final.rb:378:in `writeX
ML'
from C:/Program Files (x86)/MantisScraper/mantis_final.rb:418:in `<main>
I also tried directory_name.gsub(" ", "\s")
nothing helped...
Edit:
Batch-File:
set OUTPATH=C:\Program Files (x86)\MantisScraper\testfiles\
ruby "C:\Program Files (x86)\MantisScraper\mantis_final.rb"
Ruby-File:
Dir.mkdir(ENV['OUTPATH']) unless File.exists?(ENV['OUTPATH'])
filePath << ENV['OUTPATH'] << "test_cases.xml"
datei = File.new(filePath, "w")
The programm runs, but wants to write the xml-file in the directory C:\Program
Error-Message:
"C:\Program" konnte nicht gefunden werden. Stellen sie sicher, dass Sie den Namen richtig eingegeben haben und wiederholen sie den Vorgang.