[Mono 3.2.1]
使用Directory.GetFileSystemEntries或Directory.GetDirectories方法无法获取中文目录。为什么?
有没有办法解决这个问题?
[例如]
目录结构:
Contents
|--zipfile
|--sub
|--1.txt
|--中文.txt
|--中文
|--2.txt
代码:
string[] fileNames = Directory.GetFileSystemEntries(Server.MapPath("~/Content/zipfile"));
无法获取“中文”目录和“中文.txt”文件。
答案 0 :(得分:1)
适合我:
jcomeau@aspire:/tmp$ mcs -o test.csx test.cs
warning CS8029: Compatibility: Use -out:FILE instead of --output FILE or -o FILE
jcomeau@aspire:/tmp$ mkdir 漢語
jcomeau@aspire:/tmp$ ls
bitcoin.tmp litecoin.tmp pulse-2L9K88eMlGn7 test.cs 漢語
CRX_75DAF8CB7768 pcaresult.html pulse-PKdhtXMmr18n test.csx
jcomeau@aspire:/tmp$ mono ./test.csx
./.ICE-unix
./.X0-lock
./.X11-unix
./.google-talk-plugin-jcomeau.lock
./.org.chromium.Chromium.kFgd2O
./CRX_75DAF8CB7768
./bitcoin.tmp
./litecoin.tmp
./pcaresult.html
./pulse-2L9K88eMlGn7
./pulse-PKdhtXMmr18n
./test.cs
./test.csx
./漢語
jcomeau@aspire:/tmp$ cat test.cs
using System;
using System.IO;
public class Test {
static public void Main() {
foreach (String filename in Directory.GetFileSystemEntries(".")) {
Console.WriteLine("{0}", filename);
}
}
}