Ruby, getting path from path+filename

前端 未结 2 1140
轻奢々
轻奢々 2020-12-30 18:15

Programming language: Ruby 1.9

Problem String: C:/Test/blah.txt
to C:/Test/

I know it\'s an easy question, but Google and the R

2条回答
  •  情深已故
    2020-12-30 18:52

    Use the Ruby File.dirname method.

    File.dirname("C:/Test/blah.txt")
    # => "C:/Test" 
    

提交回复
热议问题