如何Windows文件和文件夹的快捷方式可通过C#.NET code产生的? [英] How can Windows file and folder shortcuts be created via C#.NET code?

查看:203
本文介绍了如何Windows文件和文件夹的快捷方式可通过C#.NET code产生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个资源库文件夹和文件结构与许多依赖版本控制使用.NET为我们的数据仓库。目前,我有code创建与C#code假文件和文件夹(见下文)。但是,也有被共享对象。所以,我想创建快捷方式到Windows文件和快捷方式到Windows文件夹以及文件。你会在code看起来像在C#中做到这一点?

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?

通过C#.NET code创建文件夹:

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的变化取决于基于格式的文件

Code varies depending on files based on format

推荐答案

请使用ShellClass还创建快捷方式,你会 需要使用Environment.SpecialFolder.DesktopDirectory从桌面获得特殊的目录

Please use the ShellClass to create shortcuts also you will need to get the special directory from desktop using Environment.SpecialFolder.DesktopDirectory

一个很好的例子,说明一步一步都能在这里找到的http://www.$c$cproject.com/Articles/146757/Add-Remove-Startup-Folder-Shortcut-to-Your-App

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

这篇关于如何Windows文件和文件夹的快捷方式可通过C#.NET code产生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆