作者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