Creating Shortcut where folder name is having unicode characters

大憨熊 提交于 2019-12-02 07:36:49

Reference Shell32.dll from file system, go to COM tab of the "Add ref..." dialog and select the component named "Microsoft Shell Controls And Automation"

string destPath = @"c:\temp";
string shortcutName = @"नमस्ते.lnk";

// Create empty .lnk file
string path = System.IO.Path.Combine(destPath, shortcutName);
System.IO.File.WriteAllBytes(path, new byte[0]);
// Create a ShellLinkObject that references the .lnk file
Shell32.Shell shl = new Shell32.ShellClass();
Shell32.Folder dir = shl.NameSpace(destPath);
Shell32.FolderItem itm = dir.Items().Item(shortcutName);
Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink;
// Set the .lnk file properties
lnk.Path = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\notepad.exe";
lnk.Description = "nobugz was here";
lnk.Arguments = "sample.txt";
lnk.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
lnk.Save(path);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!