This tutorial will show you the
code you need to write to have your application create shortcuts to any path (the desktop, startup folder, etc.).
Creating a shortcut from within a C# Windows application is not as easy as using a method in a namespace of the .NET
However, after you’ll be reading this tutorial, you’ll find that it’s not rocket science either. For testing purposes, you can create a Windows Forms applications, and add a button on it: btnShortcut. Double-clicking the button will bring you to the btnShortcut_Click event, where we will write some lines of code that will actually create the shortcut.
But before that, we need to add a reference to Windows Script Host Object Model. To do that, right-click the “References” folder in Solution
Explorer and choose “Add Reference”. From the COM tab, choose Windows Script Host Object Model. Double click it, and it will be added to the “Selected Components” list:
|
||||||||||||


Tháng Một 15, 2009 lúc 5:59 sáng
string deskDirDesktopDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string deskDirApplicationData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);