I am trying to show a help file (help.chm) when pressing F1 button.
The problem is whenever I use this code, everything seems to be working
HelpProvider.HelpNamespace = "C:\Help.chm"
However, when I am trying to use the file that is in my application directory, it will not work
HelpProvider.HelpNamespace = My.Application.Info.DirectoryPath & "\Help.chm"
I am not getting any errors while building the application nor when I press F1. BTW this is the rest of my code for HelpProvider
HelpProvider.SetHelpKeyword(Me, Nothing)
HelpProvider.SetHelpNavigator(Me, HelpNavigator.TableOfContents)
HelpProvider.SetShowHelp(Me, True)
Use
HelpProvider.HelpNamespace = Application.StartupPath & "\Help.chm"
Related
I have a VB WinForms app that prints PDFs using Process.Start, and it has been working fine for ages on Windows 10. Today I go to use it and get the following error message:
"No application is associated with the specified file for this operation"
Nothing has changed to cause this, I have not changed PDF Viewer or uninstalled anything. I can open a PDF by double clicking on it no problems.
I wrote a small console app to replicate the issue and prove this had nothing to do with the WinForms app:
Sub Main()
Dim pi As New Diagnostics.ProcessStartInfo
Dim url As String = "C:\PathToPDF\.pdf"
pi.FileName = url
pi.Verb = "PrintTo"
pi.CreateNoWindow = True
pi.Arguments = """Microsoft Print to PDF"""
pi.UseShellExecute = True
Console.WriteLine(url)
Diagnostics.Process.Start(pi)
Console.ReadKey()
End Sub
The above program replicates the error. I have verified that the file exists and is accessible and tried it with double slashes and single slashes, they give the same error:
"No application is associated with the specified file for this operation".
The same application is working fine on other PCs in the office.
Has anyone else had this happen, and if so how did they fix it?
My PDF viewer is PDFXChange Viewer, and it has been working fine PDFs printed using this method for years. I have not updated the program, and it says in the about page that the last installed updated was in 2016.
Regards.
If I am right, I had the same issue. Maybe you can try it in a slightly other way. I have this in my application and it works fine:
Dim myp As New Process
myp.StartInfo.FileName = filename 'Full path to pdf
myp.Start()
I have recently started getting System.UnauthorizedAccessException errors when using File.AppendAllText to write to a shared drive on the network. I think there were some changes to the network when this happened. The code in my application hasn't changed.
I have asked our IT dept to grant me full permission to the folder. I can see I have permissions for Modify, Read & Execute, Read, Write under my username if I navigate to the file and look at the Security tab under properties. I am also part of a group with read, write and modify permissions to the folder.
This works without error in the same folder:
File.WriteAllText(myFile, myText)
This generates a System.UnauthorizedAccessException error when it reaches the AppendallText:
If File.Exists(myFile) = False Then
' Create a file to write to.
Dim createText As String = logTime & " " & report_data
File.WriteAllText(myFile, createText)
Else
Dim appendText As String = logTime & " " & report_data
File.AppendAllText(myFile, appendText)
End If
I have tried deleting the file and creating it again, that made no difference.
I tried File.SetAttributes(myFile, FileAttributes.Normal)
The IT dept can't see what the problem is.
I can manually open, change and modify the file. The problem only arises if I am trying to do this programmatically.
Is there a different 'user' which tries to modify files? Could the file be open somehow, or would that generate a different error?
I'm using VB.NET 2012, .net framework 4.5, Windows 8.1
The network changes were the problem. It doesn't seem possible to resolve this as it is. Instead I made a copy of the text data, append my new text to that, delete the file, and save the updated text to a new file.
It is my first time to create a Windows Service and after read many articles on the internet, I made one by myself. It installs successfully, runs, but does not work as expected.
For example:
Inside of a Timer, I call the following code:
Public Sub WriteLog(log As String)
log = DateTime.Now.ToLongTimeString() & ", " & DateTime.Now.ToLongDateString() & vbNewLine & " -> " & log
Dim path As String = "c:\Temp\z1111.log"
Dim sw As StreamWriter
sw = File.AppendText(path)
sw.WriteLine(log)
sw.Flush()
sw.Close()
End Sub
The code above works in a Windows Form project, but as Windows Service it creates a file named z1111.log, add the content overwriting and does not do anything else, but when I delete the file, it creates again with a new date and time.
The question is: why as Windows Form it appends and as Windows Service it overwrites and stop, only works when I delete the file?
It is possible to download the project: LINK
Does anyone know how to solve it?
I solved this problem by changing the log file to the Windows folder. It has been a security issue.
I have the following code that when executed with a button(example), will Start the program rkill.exe. However when rkill.exe starts (cmdline interface), it requires the file lpt$vpn.709. How can I include this file when calling rkillProcess.Start() ?
Code- This works, but need to include lpt$vpn.709 ?
Dim rkillProcess As New Process
rkillProcess.StartInfo.FileName = My.Computer.FileSystem.CurrentDirectory & "\Tools\McAffee\rkill\rkill.exe"
rkillProcess.StartInfo.CreateNoWindow = True
rkillProcess.Start()
Of course rkill.exe runs fine if I double click it from its directory with lpt$vpn.709 included in directory. However for my programs purpose I need rkill.exeto be launched with a button event. This is why I need to include lpt$vpn.709 in order for rkill to run.
Thanks Mark!
This works:
syscleanProcess.StartInfo.WorkingDirectory = My.Computer.FileSystem.CurrentDirectory & "\Tools\TrendMicro\sysclean\"
syscleanProcess.StartInfo.FileName = My.Computer.FileSystem.CurrentDirectory & "\Tools\TrendMicro\sysclean\sysclean"
help me.. i'm new in visual basic....
when i'm running the update it shows the error
The process cannot access the file 'C:\Documents and Settings\Macky\My Documents\Visual Studio 2008\Projects\Marcelo 2.2.3\Marcelo\bin\Debug\Students\MIC953867.jpg' because it is being used by another process.
my code is this
Public Sub copingfile()
If inFileName = Nothing Then
studpic.Image = Nothing
Else
outFileName = inFileName
pos = inFileName.LastIndexOf(".")
If (pos > 0) Then
outFileName = outFileName.Substring(0, pos)
End If
outFileName += ".jpg"
str = Application.StartupPath & "\Students\"
saveJPEGFile.FileName = str & StudID.Text & ".jpg" '& outFileName
fil1.Copy(inFileName, saveJPEGFile.FileName, True) 'the error shows here...
outFileName = saveJPEGFile.FileName()
End If
End Sub
I can save new student information with picture.. but when it comes in updating the picture these codes didn't work......
fil1.Copy(inFileName, saveJPEGFile.FileName, True)
You're attempting overwrite a file that's open or being used. If the file is open in a viewer/editor, then it can't be copied over. Either you opened it manually, or did so through code and it's still "attached" to something running.
If it's not open in a window, try stopping your code and deleting that file manually. If you can, it's pretty obvious something in code is still using it when you get to the line that errored. You'll need to figure out where that file is still being used (Open stream somewhere? Open in VS, itself?), as it doesn't appear to be in the code you provided.
You are going to need to show more code, you are using variables not in your code listing. Plus you do not show the code that originally saves your image.
But here is my guess...are you sure you closed the file when you saved it for the first time? You cannot generally copy to, or from, a file that is open.
(Files can be opened as shared, but I don't think you are doing that).
Post more code if you get a chance.