如何使用C#在快捷方式文件中添加正斜杠。 [英] How to add forward slash in shortcut file create using C# .

查看:111
本文介绍了如何使用C#在快捷方式文件中添加正斜杠。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var  wsh =  new  IWshShell_Class(); 
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+ \\shorcut2.lnk as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = @ C:\ Users \Zimin \Desktop\test folder ;
shortcut.Save();



i想要使用c#创建任务调度程序的快捷方式文件。

并添加TargetPath = C :\ Windows \ System32 \schtasks.exe / RUN / TN myapplicaion。



我尝试过:



var wsh = new IWshShell_Class();

IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(

Environment.GetFolderPath(Environment .SpecialFolder.Desktop)+\\shorcut2.lnk)作为IWshRuntimeLibrary.IWshShortcut;

shortcut.TargetPath = @C:\ Users \Zimin\Desktop\test文件夹;

shortcut.Save();

解决方案

只需在代码/中键入正斜杠,它就会接受它。

例如



string myString = @C:\ Windows \ System32 \schtasks.exe / RUN / TN myapplication;

var wsh = new IWshShell_Class();
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
    Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\shorcut2.lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = @"C:\Users\Zimin\Desktop\test folder";            
shortcut.Save();


i want to create shortcut file of task scheduler using c#.
and also add TargetPath = C:\Windows\System32\schtasks.exe /RUN /TN myapplicaion .

What I have tried:

var wsh = new IWshShell_Class();
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\shorcut2.lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = @"C:\Users\Zimin\Desktop\test folder";
shortcut.Save();

解决方案

Just type the forward slash in your code "/" and it will accept it.
e.g.

string myString = @"C:\Windows\System32\schtasks.exe /RUN /TN myapplication";


这篇关于如何使用C#在快捷方式文件中添加正斜杠。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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