开发者

Ruby, unable to delete file on windows - I suspect encoding problem

Similar to this question - now I can create file "Austra Skujytė.txt" but I am unable to delete it. I suspect that it is caused by ė as other files with fancy characters are also affected. AFAIK there is no way to specify encoding like in file opening:

开发者_高级运维
out=File.open("#{file}", "a:UTF-8")

How can I fix it?


To delete the file, try using the short 8.3 filename; e.g.,

File.delete("AUSTRA~1.TXT")

You can convert a long filename to the short format using FFI:

https://github.com/ffi/ffi/wiki/Windows-Examples#wiki-intermediate

It's a bit hacky, but it may be what you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜