獲得長文件名我想要一個工具,它需要一些文件名作爲參數,但是當我使用此代碼:如何從ARGV
ARGV.each do|a|
puts "Argument: #{a}"
end
,我使用拖放或「發送到」在Windows ,我得到了短文件名。 因此像"C:\Ruby193\bin\test\New Text Document.txt"
這樣的文件變成 C:\Ruby193\bin\test\NEWTEX~1.TXT
作爲參數。
當我使用longfilenames作爲參數從命令行運行腳本時,沒有任何問題。
當我使用拖放或發送時,如何獲得長文件名?
沒有找到它 http://www.varioustopics.com/ruby/518646-rre-ruby-cygwin-and-paths.html 需要 '查找' 需要 'fileutils中' 需要 '的Win32API' DEF get_long_win32_filename(SHORT_NAME) MAX_PATH = 1024 LONG_NAME = 「」 * MAX_PATH lfn_size = Win32API.new( 「KERNEL32」, 「GetLongPathName」,[」 (short name,long_name,max_path) return(1..max_path).include?(lfn_size)? long_name [0..lfn_size-1]:短名稱 結束 ARGV.each do | a | 放一個 puts get_long_win32_filename(a) end – peter