'发快捷方式到桌面
Dim appName = My.Application.Info.CompanyName & My.Application.Info.ProductName
Dim desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
If Not fileDesktop.Exists Then
Dim shell = New WshShell()
Dim shortcut = CType(shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" & appName & ".lnk"), IWshShortcut)
shortcut.WorkingDirectory = System.Environment.CurrentDirectory
shortcut.WindowStyle = 1
shortcut.Description = appName
shortcut.IconLocation = Application.ExecutablePath
shortcut.TargetPath = Application.StartupPath + "\\" + My.Application.Info.AssemblyName & ".exe"
shortcut.Save()
End If
WshShell()与 IWshShortcut划波浪线了,是什么原因呢?百度的代码,不知道怎么写,请老师帮助写一下,谢 谢 ?
[此贴子已经被作者于2024/1/29 21:27:30编辑过]
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=183178&skin=0
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=160730&skin=0
For Each s As String In FileSys.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
If s.Contains(appName) = True Then
Return
End If
Next
vb.net环境里 filesys显示波浪线
由于foxtable经常闪退,所以我想用vb.net做一个,能帮忙吗?
'读文件路径
Dim apppath As String = Directory.GetCurrentDirectory()
Dim file As New System.IO.StreamReader(apppath & "\wjm.txt") ’保存可执行文件名
Dim wj As String = file.ReadToEnd()
file.Close()
Dim hqlj As New System.IO.StreamReader(apppath & "\lj.txt") ‘保存可执行文件上一级目录名
Dim lujingm As String = hqlj.ReadToEnd()
file.Close()
'发快捷方式到桌面
Dim appName = apppath & lujingm & wj & ".lnk"
'For Each s As String In FileSys.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
' If s.Contains(appName) = True Then
' Return
' End If
'Next
Dim FilePath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim wsh As Object = CreateObject("WScript.Shell")
Dim PathLink As String = appName
Dim wshs As Object = wsh.CreateShortcut(PathLink)
wshs.Save()
MsgBox("成功")
能帮忙改下吗?解决总闪退的难题,这个可执行文件和保存可执行文件目录处在同一级目录下,先解决这个问题,再研究改文件夹名称
此主题相关图片如下:1.png

就想执行一次修复,就改publish目录名,重新发快捷方式到桌面
[此贴子已经被作者于2024/1/29 22:18:45编辑过]
如果要使用1楼的用法:https://www.cnblogs.com/Dongmy/p/16903141.html
如果要改FileSys.GetFiles:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.directory.getfiles?view=netframework-4.0
Imports System.IO
Using IWshRuntimeLibrary
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'读文件路径
Dim apppath As String = Directory.GetCurrentDirectory()
Dim file As New System.IO.StreamReader(apppath & "\wjm.txt")
Dim wj As String = file.ReadToEnd()
file.Close()
Dim hqlj As New System.IO.StreamReader(apppath & "\lj.txt")
Dim lujingm As String = hqlj.ReadToEnd()
file.Close()
'发快捷方式到桌面
Dim appName = apppath & lujingm & wj & ".lnk"
Dim desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
If Not fileDesktop.Exists Then
Dim shell = New WshShell()
Dim shortcut = CType(shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" & appName & ".lnk"), IWshShortcut)
shortcut.WorkingDirectory = System.Environment.CurrentDirectory
shortcut.WindowStyle = 1
shortcut.Description = appName
shortcut.IconLocation = Application.ExecutablePath
shortcut.TargetPath = Application.StartupPath + "\\" + My.Application.Info.AssemblyName & ".exe"
shortcut.Save()
End If
MsgBox("成功")
End Sub
End Class 这样引用还是不行
此主题相关图片如下:1.png
已经做引用了
[此贴子已经被作者于2024/1/29 22:46:15编辑过]