问题
I'm building a repository folder and file structure with many dependencies in version control using .NET for our data warehouse. Currently I have code to create dummy files and folders with C# code (see below). However, there are objects being shared. So I'd like to create shortcuts to Windows files and shortcuts to Windows folders as well as files. What would the code look like in C# to accomplish this?
Create Folder via C#.NET code:
string activeDir = @"C:\Source\EDW\dw-objects\trunk\table-objects";
string objectName = reader[0].ToString();
string newPath = System.IO.Path.Combine(activeDir, objectName);
System.IO.Directory.CreateDirectory(newPath);
Code varies depending on files based on format
回答1:
Please use the ShellClass to create shortcuts also you will need to get the special directory from desktop using Environment.SpecialFolder.DesktopDirectory
A very good example showing step by step can be found here http://www.codeproject.com/Articles/146757/Add-Remove-Startup-Folder-Shortcut-to-Your-App
回答2:
Have a look at This Article it shows you how to manipulate NTFS Juncture points using c#. Because you will want to access the folders you need to have juncture points instead of shrotcuts since one is followed by machine processing and one isn't.
来源:https://stackoverflow.com/questions/11513681/how-can-windows-file-and-folder-shortcuts-be-created-via-c-net-code