C# 创建Url快捷方式

 string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//桌面路径
                using (StreamWriter writer = new StreamWriter(deskDir + "\\" + name + ".url"))
                {
                    writer.WriteLine("[InternetShortcut]");
                    writer.WriteLine("URL=" + url);//网址也可以是ftp地址
                    writer.WriteLine("ShowCommand=3");//浏览器打开的方式,0或者不设置是正常,3是最大,7是最小
                    writer.WriteLine("IconIndex=0");//ico的顺序,默认设置为0就可以
                    writer.WriteLine("IconFile=" + icoPath);//ICO路径,可以是dll、exe、ico等格式
                    writer.Flush();

                }

创建好快捷方式后,如果不能显示正确的ICO,可以刷新一下桌面就可以了

由于我的英语很差,大家可以查看一下我从谷歌上找到的说明,有错误的地方,欢迎大家指正!

说明:

URL: This is self-explanatory. It is the url of the internet resource. Note this is not limited to the http protocol, it can be http, https, ftp or some other supported protocols。
ShowCommand: This the state the browser should be when the URL is opened. 0 or not setting this means normal, 3 means maximized, while 7 means minimized. 
IconFile: This is the location of the file containing the icon that should be displayed for this file. This can be a .ico, .dll, .exe, or any file which can contain an icon file. Note that this is not limited to files on the local machine of the user, it can be on your webserver e.g. IconFile=http://www.example.com/myicon.ico  
IconIndex: the index of the icon to use in the file specified in IconFile.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值