Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character

Tags:

c#

I want to open file's location with window Explorer. I am using C# with code

System.Diagnostics.Process.Start("Explorer.exe", @"/select," + FilePath)

it works well with simple English character, but it could not open the file's location if the file's name is Unicode character (Thia language).

Anyone could help please?

like image 562
HIA YongKuy Avatar asked Sep 02 '11 12:09

HIA YongKuy


2 Answers

Try putting it in quotes:

System.Diagnostics.Process.Start("Explorer.exe", @"/select,""" + FilePath + "\"")
like image 72
Daniel Hilgarth Avatar answered Sep 30 '22 01:09

Daniel Hilgarth


No trouble with this code snippet:

    static void Main(string[] args) {
        string path = @"c:\temp\លួចស្រលាញ់សង្សារគេ.DAT";
        System.IO.File.WriteAllText(path, "hello");
        string txt = System.IO.File.ReadAllText(path);
    }

Windows 7, the file is created and displays correctly in Explorer. You didn't document your operating system version so that's one failure mode, albeit a very small one. Much more likely is trouble with the file system that's mapped to your E: drive. Like a FAT32 volume on a flash drive or a network redirector. Ask questions about that, respectively, at superuser.com and serverfault.com. Do not forget to document those essential details.

like image 21
Hans Passant Avatar answered Sep 30 '22 01:09

Hans Passant