[問題] 製作shortcut遇到簡體或日文就失敗。

看板C_Sharp作者 (背德之哞)時間16年前 (2010/01/17 21:26), 編輯推噓3(3015)
留言18則, 5人參與, 最新討論串1/2 (看更多)
以下是小弟的程式 ======================== 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

01/17 23:18, , 1F
MyShortcut.TargetPath = @"...";
01/17 23:18, 1F

01/17 23:21, , 2F
是變數,樓上這樣好像沒辦法套用到變數。
01/17 23:21, 2F

01/18 02:19, , 3F
xxx.TargetPath = """"+filePath+""""; //這樣可嗎?
01/18 02:19, 3F

01/18 10:55, , 4F
不行 XD
01/18 10:55, 4F

01/18 16:03, , 5F
印象中... C#中 字串(string或char)預設全都是Unicode...
01/18 16:03, 5F

01/18 16:05, , 6F
然而XP的檔案系統好像是走big5的編碼(所以簡中日文出問)
01/18 16:05, 6F

01/18 16:06, , 7F
建議裝Unicode補完計畫試試看...
01/18 16:06, 7F

01/18 16:09, , 8F
順帶一問.. 你系統裡的檔案用日文命名後 看起來正常嗎?
01/18 16:09, 8F

01/18 16:18, , 9F
試試看UTF8Encoding這個類別
01/18 16:18, 9F

01/18 16:30, , 10F
或是Encoding類別
01/18 16:30, 10F

01/18 17:35, , 11F
google "c# unicode string"
01/18 17:35, 11F

01/18 22:36, , 12F
系統裡的日文跟簡中是正常顯示的,而且也可以製作捷徑
01/18 22:36, 12F

01/18 22:37, , 13F
但是只要一用到這個類別就沒辦法接受Unicode
01/18 22:37, 13F

01/18 22:41, , 14F
我的input都是unicode的了,但是放進去之後就會變成BIG5。
01/18 22:41, 14F

01/18 22:41, , 15F
不知道有沒有大大有遇過類似的問題?
01/18 22:41, 15F

01/18 22:41, , 16F
還是說要用其它製作捷徑的方式?
01/18 22:41, 16F

01/19 07:34, , 17F
我放棄... 不知為啥指派給TargetPath的 都強制被改為big5..
01/19 07:34, 17F

01/19 10:21, , 18F
我也放棄,就當這一題無解吧! XDDD
01/19 10:21, 18F
文章代碼(AID): #1BKn0LHi (C_Sharp)
文章代碼(AID): #1BKn0LHi (C_Sharp)