且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在默认应用程序中打开文件.红宝石

更新时间:2023-10-25 18:02:10

这应该有效(未经测试,因为我现在不在Windows计算机上):

This should work (untested, as I'm not on a Windows machine now):

file_to_open = "c:\path\to\file.txt"
system %{cmd /c "start #{file_to_open}"}

作为参考,这也可以在OS X上完成:

For reference, this can also be done on OS X:

file_to_open = "/path/to/file.txt"
system %{open "#{file_to_open}"}