简体   繁体   English

如何在文件名中将/转换为\\

[英]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 “ 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 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. 将其传递给system()时,它不会启动注释电子邮件。 I think that the problem is that the server looks for / and the windows pc looks for \\ 我认为问题是服务器寻找/而Windows pc寻找\\

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)

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Rails中,如何从视图中输出动作的名称? - In Rails, how can you output the name of the action from inside the view? 您能帮我将此路线转换为Rails 3吗? - Can you help me convert this route to rails 3? 您可以在Heroku上将Rails应用程序转换为Sinatra吗 - Can you convert a Rails app to Sinatra on Heroku 如何将Rails 5 API应用程序转换为可以充当API和应用程序的rails应用程序? - How do you convert a Rails 5 API app to a rails app that can act as both API and app? 如何在 Rails / Paperclip / S3 上更新 Ruby 中的文件? - How can you update a file in Ruby on Rails / Paperclip / S3? 如何将所有迁移文件转换为Rails中的单个文件? - How can I convert all migration files into a single file in Rails? 如何根据Rails中的字段名称自动生成占位符文本? - How can you auto-generate placeholder text based on the field name in Rails? 您如何提供A名称/子域重定向到Rails应用程序? - How can you provide an A-name/sub-domain redirect to a Rails app? 你能在 Rails 中获取数据库用户名、密码、数据库名称吗? - Can you get DB username, pw, database name in Rails? 你能在 Rails 中定义多个同名的动作吗? - Can you define multiple actions with the same name in Rails?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM