Forum guidelines
  • Home
  • »
  • Windows Azure
  • »
  • C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
AuthorQuestion
C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
Posted on: 02 Sep 2011

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?


AuthorReply
Re: C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
Posted on: 02 Sep 2011  
I take it that these files open OK 'manually' from Windows Explorer?

If you can figure out what the unicode values are for the Thai characters (see table in http://en.wikipedia.org/wiki/Thai_alphabet), I'd try replacing each such character in the FilePath string with \uxxxx where 'xxxx' is its Unicode value in hex.

Re: C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
Posted on: 02 Sep 2011  
It is not an easy thing to do like that...

Re: C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
Posted on: 02 Sep 2011  
I know but, if you could try it with a very short file name, it will tell us whether there's any merit in this suggestion which is the only one I have :)

Otherwise, I'd wait for more answers.

Re: C#: System.Diagnostics.Process.Start("Explorer.exe", @"/select" + FilePath). Can not open file when file's name is unicode character
Posted on: 02 Sep 2011  
How are you getting the "FilePath" value? You need to provide the Unicode characters, correct? Are you doing that? For example, if you are entering the name using a TextBox then you must be able to enter the Unicode characters into it. On that subject, I am not sure if the font used for the form with the text box is relevant. If the font is not a Unicode font then that is a likely problem and I don't know if Windows Forms always uses Unicode fonts. As far as I know, there are few Unicode fonts in most systems.

Also, are you sure that the file path (including name and extension) is 260 characters or less? If not then it will not work unless you use Universal Naming Convention (UNC) names.

Also note that questions in forums won't work if you say things like "could not" without an explanation. What does happen? Your question might work much better (you might get an answer) if you clarify what "could not" means.

Finally, try the following for diagnostic purposes. Go to the folder with the file (one of them) using the Windows Explorer. Go to the folder's properties and copy the path and paste that into a C# program. If you need to, you can create a test program in less than a minute. Then do the same for the file's name and put all that in a string constant with a backslash and all to make a complete path. Then try opening Windows Explorer with that. If that "works" then you know it is possible and you just need to figure out how to get the correct path into your program. If it does not work then you have significantly limited the direction you need to go to diagnose the problem.

Thinking is a feeling; pleasant for some and unpleasant for others.

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.