找了一段生成ClickOne的快捷方式的生成代码

找了一段生成ClickOne的快捷方式的生成代码,晚上回去试试能否可用。

 

void CheckForShortcut()

{

ApplicationDeployment ad
= ApplicationDeployment.CurrentDeployment;



if (ad.IsFirstRun)

{

Assembly code
= Assembly.GetExecutingAssembly();



string company = string.Empty;

string description = string.Empty;



if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))

{

AssemblyCompanyAttribute ascompany
= (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code,

typeof(AssemblyCompanyAttribute));

company
= ascompany.Company;

}



if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))

{

AssemblyDescriptionAttribute asdescription
= (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code,

typeof(AssemblyDescriptionAttribute));

description
= asdescription.Description;

}



if (company != string.Empty && description != string.Empty)

{

string desktopPath = string.Empty;

desktopPath
= string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),

"\\", description, ".appref-ms");



string shortcutName = string.Empty;

shortcutName
= string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),

"\\", company, "\\", description, ".appref-ms");



System.IO.File.Copy(shortcutName, desktopPath,
true);

}



}

}

posted @ 2011-09-08 10:23  生命体验之kevin-Y  阅读(339)  评论(0编辑  收藏  举报