作者senjor (背德之哞)
看板C_Sharp
標題[問題] 製作shortcut遇到簡體或日文就失敗。
時間Sun Jan 17 21:26:37 2010
以下是小弟的程式
========================
WshShellClass myWshShell;
// Create a new instance of WshShellClass
myWshShell = new WshShellClass();
// Create the shortcut
IWshRuntimeLibrary.IWshShortcut MyShortcut;
// Choose the path for the shortcut
MyShortcut =
(IWshRuntimeLibrary.IWshShortcut)myWshShell.CreateShortcut(name + ".lnk");
// Where the shortcut should point to
MyShortcut.TargetPath =
filePath;
// Create the shortcut at the given path
MyShortcut.Save();
=======================
就是FilePath的地方沒有辦法接受簡體字或日文
有沒有什麼方法可以讓他變成Unicode呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.147.70
1F:→ pico2k:MyShortcut.TargetPath = @"..."; 01/17 23:18
2F:→ senjor:是變數,樓上這樣好像沒辦法套用到變數。 01/17 23:21
3F:推 wvsrugby:xxx.TargetPath = """"+filePath+""""; //這樣可嗎? 01/18 02:19
4F:→ senjor:不行 XD 01/18 10:55
5F:→ bdvstg:印象中... C#中 字串(string或char)預設全都是Unicode... 01/18 16:03
6F:→ bdvstg:然而XP的檔案系統好像是走big5的編碼(所以簡中日文出問) 01/18 16:05
7F:→ bdvstg:建議裝Unicode補完計畫試試看... 01/18 16:06
8F:→ bdvstg:順帶一問.. 你系統裡的檔案用日文命名後 看起來正常嗎? 01/18 16:09
9F:推 dna2me:試試看UTF8Encoding這個類別 01/18 16:18
10F:推 dna2me:或是Encoding類別 01/18 16:30
11F:→ pico2k:google "c# unicode string" 01/18 17:35
12F:→ senjor:系統裡的日文跟簡中是正常顯示的,而且也可以製作捷徑 01/18 22:36
13F:→ senjor:但是只要一用到這個類別就沒辦法接受Unicode 01/18 22:37
14F:→ senjor:我的input都是unicode的了,但是放進去之後就會變成BIG5。 01/18 22:41
15F:→ senjor:不知道有沒有大大有遇過類似的問題? 01/18 22:41
16F:→ senjor:還是說要用其它製作捷徑的方式? 01/18 22:41
17F:→ bdvstg:我放棄... 不知為啥指派給TargetPath的 都強制被改為big5.. 01/19 07:34
18F:→ senjor:我也放棄,就當這一題無解吧! XDDD 01/19 10:21