简体   繁体   中英

rails how can you convert / to \ in a file name

I am working on selecting files to email and then passing them to the user's notes email client.

The string I want to send to the system command should be in the format of:

"C:\\Program Files (x86)\\IBM\\Lotus\\Notes\\notes.exe" Mailto:chris@mydomain.com?Subject=MailSubject?Attach=C:\\test.bat

However, the code

 $attached_files =   $attached_files + "?Attach="+ Rails.root.to_s + "/public/images/" + document.id.to_s + "/" + document.doc_file_file_name

gives me forward slashes instead:

C:/Users/cmendla/RubymineProjects/technical_library/public/images/2/High_Durability.pdf

When that is passed to system() it won't launch the notes email. I think that the problem is that the server looks for / and the windows pc looks for \\

Is there any way to easily change / to \\ at least for the time being for testing?

Have you tried

 Rails.root.join("public","images", document.id, document.doc_file_file_name)

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM