-
Sep 12th, 2023, 09:29 PM
#1
Thread Starter
Lively Member
[RESOLVED] PDF Files in VB Project
Good Day,
I am having a problem with the following: -

On the Top of the form, I have 2 buttons "Help" and "License Agreement". These files is in a PDF format as well as in a word format. If one clicks on the button, it opens automatically with the following codes
Private Sub btnEULA_Click(sender As Object, e As EventArgs) Handles btnEULA.Click
System.Diagnostics.Process.Start("C:\Program Files\EULA1.pdf")
End Sub
Private Sub btnHelp_Click(sender As Object, e As EventArgs) Handles btnHelp.Click
System.Diagnostics.Process.Start("C:\Program Files\Symbolic Signs Help File.pdf")
End Sub
Unfortunately some users do not understand to copy these 2 files in the correct Folder for these buttons to work and I am looking how to code it to automatically include these files to work with the buttons when the software is installed.
I wanted to include them in the Application Files when publishing the setup file, but it appears that one cannot include PDF nor Word Files.
Is there a way I can do this Programmatically?
-
Sep 12th, 2023, 09:41 PM
#2
Re: PDF Files in VB Project
 Originally Posted by kobusjhg
Unfortunately some users do not understand to copy these 2 files in the correct Folder for these buttons to work and I am looking how to code it to automatically include these files to work with the buttons when the software is installed.
You seem to understand the downside of how you currently have this coded, but just to underscore the point, it is a horrible coding and deployment strategy for your application to only work properly if the end user needs to manually copy files anywhere, let alone the root of the Program Files folder, which an end user wouldn't even have permissions to do if your company is doing security properly.
-
Sep 12th, 2023, 09:56 PM
#3
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by OptionBase1
You seem to understand the downside of how you currently have this coded, but just to underscore the point, it is a horrible coding and deployment strategy for your application to only work properly if the end user needs to manually copy files anywhere, let alone the root of the Program Files folder, which an end user wouldn't even have permissions to do if your company is doing security properly.
I do agree with you completely. This is one of the reasons I would like it to be changed, and as I have stated I have tried various options to do that.
-
Sep 12th, 2023, 10:08 PM
#4
Re: PDF Files in VB Project
You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.
-
Sep 12th, 2023, 10:19 PM
#5
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by jmcilhinney
You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.
Thank You jmcilhinney, I am going to try that and reply back to you. I have tried to add it to the project Via the "Add Item" mode, but as I have said it did not work. I will do it this way. Thank You.
-
Sep 12th, 2023, 11:15 PM
#6
Re: PDF Files in VB Project
If the files already exist then you should use Add Existing Item and then browse to the file.
-
Sep 12th, 2023, 11:17 PM
#7
Re: PDF Files in VB Project
I have moved this thread to the Application Deployment forum because that's really what the issue is about, rather than actual VB.NET. You should also explain exactly how you are creating the installer. Are you using ClickOnce, i.e. the publishing functionality built into the project, or creating a Setup project or something else?
-
Sep 13th, 2023, 06:22 AM
#8
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by jmcilhinney
I have moved this thread to the Application Deployment forum because that's really what the issue is about, rather than actual VB.NET. You should also explain exactly how you are creating the installer. Are you using ClickOnce, i.e. the publishing functionality built into the project, or creating a Setup project or something else?
I am using on the top menu
Project
Program properties
Publish
If I want to add the files
I go to Solution Explorer
Right Click My Project
Add Existing Item
I add the 2 files after I was asked to replace them and I replace them
I deleted the Button Code I have written. before
I go to Publish Wizard
I have selected a folder "Publish" where my Installation File will be Saved in
I install the program, it installs, but still does not open the files.
This is where I am Stuck now.
-
Sep 13th, 2023, 08:48 AM
#9
Re: PDF Files in VB Project
 Originally Posted by kobusjhg
I deleted the Button Code I have written. before
I go to Publish Wizard
I have selected a folder "Publish" where my Installation File will be Saved in
I install the program, it installs, but still does not open the files.
This is where I am Stuck now.
After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?
You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.
-
Sep 13th, 2023, 11:29 AM
#10
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by OptionBase1
After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?
You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.
Nope, Seems I expected magic to happen.
Thanx, Let me go back and re-do
-
Sep 14th, 2023, 11:18 AM
#11
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by OptionBase1
After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?
You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.
I put the code back, the 2 files is in the folder. It does not work when I execute the program.
-
Sep 14th, 2023, 12:45 PM
#12
Re: PDF Files in VB Project
 Originally Posted by kobusjhg
I put the code back, the 2 files is in the folder. It does not work when I execute the program.
That's a shame.
-
Sep 14th, 2023, 12:55 PM
#13
Re: PDF Files in VB Project
It's frustrating when people insist on being lazy explaining their problem because then we have waste our time and yours dragging the information out of you. Telling us "it doesn't work" it's all but useless when you don't show us what "it" is or tell us what it actually does. Show us the code and explain what actually happens. For a start, did you do what I instructed and use Application.StartupPath for the folder?
-
Sep 14th, 2023, 12:58 PM
#14
Re: PDF Files in VB Project
So you put the code back so that it looks like this again?
Code:
System.Diagnostics.Process.Start("C:\Program Files\EULA1.pdf")
sigh... if so, that's why it doesn't work... the pdf files are not at that location ... where are they? they're with the application ... fortunately there is a method to get the application.path ...
-tg
-
Sep 14th, 2023, 01:19 PM
#15
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by jmcilhinney
You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.
I do not find the Content option in VB. I came across it in C# once.
I do my Installation File as follow: -
Project
Add Item
New
Sorry jmcilhinney,
I found it on the right hand side.
how bloody stupid of me.
I will do it and see if it works.
I deleted my Button code and it works perfectly.
Last edited by kobusjhg; Sep 14th, 2023 at 01:55 PM.
-
Sep 14th, 2023, 02:58 PM
#16
Re: [RESOLVED] PDF Files in VB Project
-
Sep 14th, 2023, 09:42 PM
#17
Thread Starter
Lively Member
Re: PDF Files in VB Project
 Originally Posted by jmcilhinney
It's frustrating when people insist on being lazy explaining their problem because then we have waste our time and yours dragging the information out of you. Telling us "it doesn't work" it's all but useless when you don't show us what "it" is or tell us what it actually does. Show us the code and explain what actually happens. For a start, did you do what I instructed and use Application.StartupPath for the folder?
Thanx Again jmcilhinney,
It is working. I am sorry for being frustrating and wasting everybody's time, but I think it is trying to explain College Maths to a 11 yr old. At last with all your help jmcilhinney, OptionBase1, techgnome I got it right by opening my eyes and look for the right stuff as explained by you all.
-
Sep 14th, 2023, 10:06 PM
#18
Re: [RESOLVED] PDF Files in VB Project
It's not the end of the world if we get frustrated but, if we get too frustrated, we may decide to not help any more and that would be bad for you. Whenever you post here or in a similar site, ALWAYS stop and think about what information is relevant to the issue. Whether it's the first post in a thread or not, ALWAYS answer the questions "what am I trying to achieve", "how am I trying to achieve it" and "what happens when I try". The last5 one is important because different behaviour is indicative of different issues, so we have an idea of what we're looking for.
-
Sep 15th, 2023, 09:14 AM
#19
Thread Starter
Lively Member
Re: [RESOLVED] PDF Files in VB Project
 Originally Posted by jmcilhinney
It's not the end of the world if we get frustrated but, if we get too frustrated, we may decide to not help any more and that would be bad for you. Whenever you post here or in a similar site, ALWAYS stop and think about what information is relevant to the issue. Whether it's the first post in a thread or not, ALWAYS answer the questions "what am I trying to achieve", "how am I trying to achieve it" and "what happens when I try". The last5 one is important because different behaviour is indicative of different issues, so we have an idea of what we're looking for.
Agreed, I will try my best to improve.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|