Results 1 to 36 of 36

Thread: [RESOLVED] Copy File From A Folder to another Folder and open it with a button

  1. #1

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Resolved [RESOLVED] Copy File From A Folder to another Folder and open it with a button

    Sorry Everybody, This post is in the wrong place. I reposted it as a new thread on its own, but I am not able to delete it.

    Good day everybody,

    This is Visual Studio 2020, Windows 10 and VB.Net

    I do not know if it can be done.
    I am trying to do the following: -


    I have a Button named btnCopy on a form. My intention is to find a file from the Installation CD where the Setup or Installation File is, and copy it to the Folder where the program is going to be installed. The reason behind this is in order for all users who are going to use the program to be able to open the file when another button btnShow is clicked.


    Below is my codes: -

    Code to Copy the file From the CD to the Installation Folder with btnCopy

    My.Computer.FileSystem.CopyFile(
    "D:\Text1.pdf",
    "C:\Users\Kobus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\My Name\Text1.pdf",
    Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
    Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)


    Code to Open and Show the file with btnShow

    Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
    System.Diagnostics.Process.Start("C:\Users\User Name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\My Name\Text1.pdf")
    End Sub

    The challenge is that all users might not have the CD Drives as D:\. Some users might have something else.
    I am also not sure whether my coding is correct for the buttons btnCopy and btnShow
    Last edited by kobusjhg; Sep 20th, 2023 at 12:16 PM.

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Storing a PDF file in the Start Menu directly is a terrible practice.

    That said, if your question is, can clicking a button cause two distinct things to happen consecutively, then of course the answer is yes.

  3. #3
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Not entirely sure what you are asking, if you have two bits of code and want both to run when you click a button you would just put both bits of code in the click event.

    However... You are copying a pdf to the start menu, it is more common for the start menu to contain shortcuts to the files rather than the files themselves.

    You said you want to copy the file to where the program is installed, but you also mentioned an installer; if you have an installer them it should copy the files to wherever the application is being installed and it should create the start menu items too.

    It might help if you explained what, and why, you are trying to do.

  4. #4

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    The user should copy the single file and open it from his PC. This is a domestic program not to be sold only to use as an internal program. The user should copy the file from the cd to his installation folder after the program was installed with a button and open it with another button when he wants to view it.

    The file will be on the installation cd next to the setup file
    Last edited by kobusjhg; Sep 20th, 2023 at 12:28 PM.

  5. #5

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    Storing a PDF file in the Start Menu directly is a terrible practice.

    That said, if your question is, can clicking a button cause two distinct things to happen consecutively, then of course the answer is yes.
    I actually want to store it on the installation CD to be copied and viewed in the program as and when required

  6. #6
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    I actually want to store it on the installation CD to be copied and viewed in the program as and when required
    Ok. So, for your program to be fully usable, the user has to keep the installation CD in their CD-ROM drive at all times?

    Besides, the code you posted specifically shows that you are trying to copy the pdf file to a subfolder of the Start Menu. If that isn't what you want, then why did you write and post that code?

    You had another thread recently where you wanted assistance including PDF files in an installation package. I thought you had that figured out? I guess not.

    Good luck with this.

  7. #7

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    Not entirely sure what you are asking, if you have two bits of code and want both to run when you click a button you would just put both bits of code in the click event.

    However... You are copying a pdf to the start menu, it is more common for the start menu to contain shortcuts to the files rather than the files themselves.

    You said you want to copy the file to where the program is installed, but you also mentioned an installer; if you have an installer them it should copy the files to wherever the application is being installed and it should create the start menu items too.

    It might help if you explained what, and why, you are trying to do.
    The user should copy the single file and open it from his PC. This is a domestic program not to be sold only to use as an internal program. The user should copy the file from the cd to his installation folder after the program was installed with a button and open it with another button when he wants to view it.

    The file will be on the installation cd next to the setup file

    It would be perfect if it could be done with one button

  8. #8
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    The user should copy the single file and open it from his PC. This is a domestic program not to be sold only to use as an internal program. The user should copy the file from the cd to his installation folder after the program was installed with a button and open it with another button when he wants to view it.

    The file will be on the installation cd next to the setup file
    No, the user shouldn't have to do any of that. Anything that is needed for your program to work should be installed with the program.

    Good luck.

  9. #9

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    No, the user shouldn't have to do any of that. Anything that is needed for your program to work should be installed with the program.

    Good luck.
    Ok Thank you for the valuable info

  10. #10

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    Ok. So, for your program to be fully usable, the user has to keep the installation CD in their CD-ROM drive at all times?

    Besides, the code you posted specifically shows that you are trying to copy the pdf file to a subfolder of the Start Menu. If that isn't what you want, then why did you write and post that code?

    You had another thread recently where you wanted assistance including PDF files in an installation package. I thought you had that figured out? I guess not.

    Good luck with this.

    That was actually something else, but thank you

  11. #11
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    That was actually something else, but thank you
    But wouldn't an installer be the correct way of doing this as well?

  12. #12

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    But wouldn't an installer be the correct way of doing this as well?
    Yes
    It would be, but I was just trying something else.

  13. #13
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    Yes
    It would be, but I was just trying something else.
    Just seemed a strange approach given that back in post #7 you said

    Quote Originally Posted by kobusjhg View Post
    The file will be on the installation cd next to the setup file
    if you already have a setup program, this seems a lot more work and effort than just getting the setup to install the pdf / create start menu items along with the rest of the installation steps.

  14. #14
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    Yes
    It would be, but I was just trying something else.
    At this point, I don't think we have a clear explanation of what the scenario is or why you can't deploy this pdf file with your installer as you seem to have done with other pdf files.

    If this is resolved, please mark the thread as resolved. If not, please provide a clearer explanation of what the end goal is here and what troubles you are having achieving that goal.

    Without further clarification from you, I suspect this thread will have run its useful course.

  15. #15

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    At this point, I don't think we have a clear explanation of what the scenario is or why you can't deploy this pdf file with your installer as you seem to have done with other pdf files.

    If this is resolved, please mark the thread as resolved. If not, please provide a clearer explanation of what the end goal is here and what troubles you are having achieving that goal.

    Without further clarification from you, I suspect this thread will have run its useful course.
    Thank You, Probably I have difficulty in explaining this properly to you. Maybe my limited knowledge of the English Language and my Limited knowledge of coding might be not in my favour.

    All I intend to do (although it is a really bad way to do it) is to find another option to do this. It has nothing to do of what I have done previously.

    Previously I have done this
    Project
    Add Existing Item
    Click All Files
    Add the file to the project
    Click on the file in Solution Explorer
    In File Properties Select
    Content and copy always

    Now I want to do it with a button.

    Thank You

  16. #16
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    So, the situation is, you want to copy a pdf file from a source, possibly an installation cd, only the source path isn't knowable by you ahead of time because drive letters may differ based on the machine in use.

    And you want to copy that pdf file to a destination, and that destination path may or may not be knowable ahead of time, you haven't said for sure.

    And you'd rather do this than bundle the pdf in the installation package because, well, because you just want to do it that way.

    Just dropping that explanation for the next poor sap who comes along and tries to help...

    Good luck.

  17. #17
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    Thank You, Probably I have difficulty in explaining this properly to you. Maybe my limited knowledge of the English Language and my Limited knowledge of coding might be not in my favour.

    All I intend to do (although it is a really bad way to do it) is to find another option to do this. It has nothing to do of what I have done previously.

    Previously I have done this
    Project
    Add Existing Item
    Click All Files
    Add the file to the project
    Click on the file in Solution Explorer
    In File Properties Select
    Content and copy always

    Now I want to do it with a button.

    Thank You
    That isn't making a great deal of sense, everything you are doing there is part of the software development side of things, including what happens when you build the application.

    To say you "want to do it with a button" makes no sense, as the running application has nothing to do with the VS source files.

  18. #18

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    That isn't making a great deal of sense, everything you are doing there is part of the software development side of things, including what happens when you build the application.

    To say you "want to do it with a button" makes no sense, as the running application has nothing to do with the VS source files.
    Ok Thank You. I do see that.

  19. #19

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    That isn't making a great deal of sense, everything you are doing there is part of the software development side of things, including what happens when you build the application.

    To say you "want to do it with a button" makes no sense, as the running application has nothing to do with the VS source files.
    Thank You everybody who assisted me with this,
    I think that every software has either a link or a button to access Help and the Licence Agreement.
    Attachment 188759

    I have done this with the following Codes

    Private Sub btnOpenHelp_Click(sender As Object, e As EventArgs) Handles btnOpenHelp.Click
    My.Computer.FileSystem.CopyFile(
    "D:\Programs\Database\programs\Publish\Symbolic Signs\Symbolic Signs Help File.pdf",
    "C:\Symbolic Signs Help File.pdf",
    Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
    Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)


    System.Diagnostics.Process.Start("C:\Symbolic Signs Help File.pdf")

    End Sub

    The part in red is actually copying the file from the CD D:\ Drive to the C:\ Drive.
    Most of the users CD Drives is D:\ Drive and therefore copy it from the D:\ Drive.
    If the CD Drive is something else I will have to make a plan to change it for that user.
    The file is being copied to C:\Drive in order it to be sort of standard for all users and for everybody to be able to open it.

    The part in Yellow is actually opening the file to be viewed and read.

    There is a few things I still have to look at for example
    Attachment 188760 Coming up, but otherwise it is working as intended to read and view the
    Help File as well as the License Agreement File

  20. #20
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Please explain why you think that this:

    Process of a post-installation, code controlled copying of a file from a "not guaranteed to even exist path if the CD-ROM has a letter other than D, or if the end user doesn't have your install CD in the CD-ROM drive that does have a letter of D" to a terrible location for document storage (I.E. the root of the C:\ Drive)

    is a good idea. I will offer no further suggestions until you offer a logical explanation for that.

  21. #21
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    To your credit, you've admitted in your other threads that you are not an expert and a lot of this is new to you.

    One very frustrating thing for those of us posting here trying to help others is for someone new like you to dig themselves in, and insist on doing something in a very backwards way.

    You're free to write whatever code you want to write, but you should at least be able to defend why you are choosing a certain approach.

  22. #22
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    I think that every software has either a link or a button to access Help and the Licence Agreement.
    Attachment 188759
    Those applications that have the agreement as a separate file would install the separate file during the installation, not expect the user to go and find the original install media at a later date. Just install the pdf along with the application, it will be so much easier.

    Quote Originally Posted by kobusjhg View Post
    The part in red is actually copying the file from the CD D:\ Drive to the C:\ Drive.
    Most of the users CD Drives is D:\ Drive and therefore copy it from the D:\ Drive.
    If the CD Drive is something else I will have to make a plan to change it for that user.
    The file is being copied to C:\Drive in order it to be sort of standard for all users and for everybody to be able to open it.
    This would all be unnecessary if you just installed the file when you installed the application. Also you shouldn't just dump your files directly in the root of the C: drive - firstly people may not have permission to write there, secondly imagine what would happen if everyone did just that, and thirdly anyone like me would delete things they found there that didn't belong there. Just install the file into the same folder as the application.

    Also, the attachments aren't viewable - this is a known bug on the forum in some situations.

  23. #23

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    Please explain why you think that this:

    Process of a post-installation, code controlled copying of a file from a "not guaranteed to even exist path if the CD-ROM has a letter other than D, or if the end user doesn't have your install CD in the CD-ROM drive that does have a letter of D" to a terrible location for document storage (I.E. the root of the C:\ Drive)

    is a good idea. I will offer no further suggestions until you offer a logical explanation for that.
    I do agree with you on both of your statements. The D Drive is one of the problems I am still looking at solving. Maybe to try and Code it to search or use the drive where the CD has been inserted. I chose the C drive to install the file for the following Reason: -
    The program gets installed currently in C:\Users\Kobus\Appdata\Roaming\Microsoft\Windows\Start Menu\Programs\Developer Name\ Program Executing File.
    It is using my name (in Green) in the path. Other users will have their own names and then the code will not work. I am still figuring out how to install the program in a proper path with a separate folder maybe to install under program Files or so. Secondly I got anxious to see whether my code is working.

  24. #24

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    To your credit, you've admitted in your other threads that you are not an expert and a lot of this is new to you.

    One very frustrating thing for those of us posting here trying to help others is for someone new like you to dig themselves in, and insist on doing something in a very backwards way.

    You're free to write whatever code you want to write, but you should at least be able to defend why you are choosing a certain approach.
    I do not think it is a question of digging myself in or insisting in doing it in a backwards way.

    Previously I have done this as per advice of you gentleman.

    Project
    Add Existing Item
    Click All Files
    Add the file to the project
    Click on the file in Solution Explorer
    In File Properties Select
    Content and copy always

    This procedure has done everything, created the file, created the .deploy files in the application folder, but I am still not yet smart enough to make it work the way it should I suppose. I also intend to do some of the things myself as well and try not to irritate the experts who are really giving good advice and can do this mickey mouse coding with closed eyes. I have mentioned somewhere and I am serious about it. If a College Professor explain maths the way he explains it to College Students to a 15 Year old, it will take some time. I do not know whether I have explained it properly.

  25. #25
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    I do agree with you on both of your statements.
    Then why are you carrying on with this really strange approach?

    Quote Originally Posted by kobusjhg View Post
    The D Drive is one of the problems I am still looking at solving. Maybe to try and Code it to search or use the drive where the CD has been inserted.
    It wouldn't be a problem if you just installed the pdf file alongside your application, what benefit do you see from getting the user to install your application - but it only installing most of the required files, then requiring them to do something else to install the last file? This is making more work for everyone, especially you!

    Quote Originally Posted by kobusjhg View Post
    I chose the C drive to install the file
    That doesn't explain or justify putting the file in the root of the C: drive, just install it in the same folder as your application - that would seem to be the obvious choice.

    Quote Originally Posted by kobusjhg View Post
    The program gets installed currently in C:\Users\Kobus\Appdata\Roaming\Microsoft\Windows\Start Menu\Programs\Developer Name\ Program Executing File.
    That is completely the wrong place to install the application to, that is the Start Menu, that is where the shortcuts to your application files go, not the application itself.

    Quote Originally Posted by kobusjhg View Post
    It is using my name (in Green) in the path. Other users will have their own names and then the code will not work. I am still figuring out how to install the program in a proper path with a separate folder maybe to install under program Files or so. Secondly I got anxious to see whether my code is working.
    Either install the application for everyone by putting it in the "Program Files" or "Program Files (x86)" as appropriate, if you want to install it on a per user basis then somewhere like the AppData folder might be a better option. This is something your installer should be doing though, and your installer should be installing all the required files, there should be absolutely no need for all of this extra work.

    If you insist on doing things in this way then your ideas of discovering which drive letter(s) is(are) the CD(s), searching the CD(s) might work, however this will rely on the CD being present, having a suitable error handler in case it isn't, figure out what to do if the CD isn't present and the user doesn't have it handy to put in the CD drive, the user having permission to copy things to the c: root or to "Program files" (unlikely, and if they do that is a bigger issue in itself).

    If you insist on this approach you can find threads on here to help with just about all of the individual ideas, but I honestly can't recommend your approach and personally I won't be offering any more help if you are insisting on this way of doing things. Everything you are trying to do should be done by the installer. End of story

  26. #26
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    I do not think it is a question of digging myself in or insisting in doing it in a backwards way.

    Previously I have done this as per advice of you gentleman.

    Project
    Add Existing Item
    Click All Files
    Add the file to the project
    Click on the file in Solution Explorer
    In File Properties Select
    Content and copy always

    This procedure has done everything, created the file, created the .deploy files in the application folder, but I am still not yet smart enough to make it work the way it should I suppose. I also intend to do some of the things myself as well and try not to irritate the experts who are really giving good advice and can do this mickey mouse coding with closed eyes. I have mentioned somewhere and I am serious about it. If a College Professor explain maths the way he explains it to College Students to a 15 Year old, it will take some time. I do not know whether I have explained it properly.
    What do you mean specifically by
    make it work the way it should
    ? That isn't enough for us to go on. If you are including the PDF as part of the installer it should be being installed in the same folder as your application. That way you should be able to launch it from the application's folder, this sounds an easy problem to fix if we have the details, without needing your complicated approach.

  27. #27

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    Those applications that have the agreement as a separate file would install the separate file during the installation, not expect the user to go and find the original install media at a later date. Just install the pdf along with the application, it will be so much easier.


    This would all be unnecessary if you just installed the file when you installed the application. Also you shouldn't just dump your files directly in the root of the C: drive - firstly people may not have permission to write there, secondly imagine what would happen if everyone did just that, and thirdly anyone like me would delete things they found there that didn't belong there. Just install the file into the same folder as the application.

    Also, the attachments aren't viewable - this is a known bug on the forum in some situations.
    This would be ideal yes. Remember I am fairly stupid. I have deployed the file as I have said. I further do not get it to work and do not know how the user is going to view them without a link or a button.

    a Few of the experts have already indicated that they will not communicate with me anymore. That is ok I understand hat completely. I probably will maybe leave the forum as well and try and solve things on my own. I just wish here in SA were institutions teaching these subjects part time.

    The main fact is, I am enjoying this coding thing very much an is still going to teach myself even though I am already 64 Years old.

  28. #28

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    What do you mean specifically by ? That isn't enough for us to go on. If you are including the PDF as part of the installer it should be being installed in the same folder as your application. That way you should be able to launch it from the application's folder, this sounds an easy problem to fix if we have the details, without needing your complicated approach.
    I am missing something somewhere.
    The .pdf file was added as an item, it was deployed, it reflects in the applications folder as deployed files, but it does not appear that it is in the installation setup file. If it is in the setup installation file, how get I to view it. Lastly it also does not seem that I can specify a folder where to install the file. The installer installs the program in the wrong place by default. I assumed that it should be like that.

  29. #29
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    The .pdf file was added as an item, it was deployed, it reflects in the applications folder as deployed files, but it does not appear that it is in the installation setup file.
    If the pdf file is being deployed, then it is part of the setup files. Looks like you are managing to install the pdf file, that means the other steps you are trying to do in regard to copying the file aren't needed. The file is already installed.

    Quote Originally Posted by kobusjhg View Post
    If it is in the setup installation file, how get I to view it.
    If you mean view it at runtime, then you can use code like your original, you just need to look in the folder the application is installed in for the file. Something like the following should work...

    Code:
    Process.Start( Path.Combine(Application.StartupPath, "Text1.pdf"))
    Quote Originally Posted by kobusjhg View Post
    Lastly it also does not seem that I can specify a folder where to install the file. The installer installs the program in the wrong place by default. I assumed that it should be like that.
    ClickOnce installs don't allow you to control where an application is installed to, each user would get their own copy of the application. If you want a more traditional deployment you would need to use a different type of installer.

    https://marketplace.visualstudio.com...tallerProjects might be worth a look as it allows you to build a simple, but more typical, installer - this will give control over the install location etc.

  30. #30

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    If the pdf file is being deployed, then it is part of the setup files. Looks like you are managing to install the pdf file, that means the other steps you are trying to do in regard to copying the file aren't needed. The file is already installed.


    If you mean view it at runtime, then you can use code like your original, you just need to look in the folder the application is installed in for the file. Something like the following should work...

    Code:
    Process.Start( Path.Combine(Application.StartupPath, "Text1.pdf"))


    ClickOnce installs don't allow you to control where an application is installed to, each user would get their own copy of the application. If you want a more traditional deployment you would need to use a different type of installer.

    https://marketplace.visualstudio.com...tallerProjects might be worth a look as it allows you to build a simple, but more typical, installer - this will give control over the install location etc.
    PlausiblyDamp, Thank you, I am going to follow your valuable advice. Will it be ok if I respond afterwards?

  31. #31
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,301

    Re: Copy File From A Folder to another Folder and open it with a button

    OF course, always happy to help when my advice is being heeded

  32. #32

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by PlausiblyDamp View Post
    OF course, always happy to help when my advice is being heeded
    Wow!!!
    I put in this code as you have said: -
    Private Sub btnLicenseAgreement_Click(sender As Object, e As EventArgs) Handles btnLicenseAgreement.Click
    System.Diagnostics.Process.Start(Path.Combine(Application.StartupPath, "Eula1.pdf"))
    End Sub

    I created a new setup file, copied the installation folder to a flash disk and installed it on a laptop with no DVD/CD Rom. I still have the button with the above code.

    Guess What? It worked perfectly. No need to copy anything or changing code to find the DVD\CD Rom Drives. I deleted the PDF File in C:\.

    Thank You very much.

  33. #33
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    a Few of the experts have already indicated that they will not communicate with me anymore. That is ok I understand hat completely. I probably will maybe leave the forum as well and try and solve things on my own. I just wish here in SA were institutions teaching these subjects part time.

    The main fact is, I am enjoying this coding thing very much an is still going to teach myself even though I am already 64 Years old.
    For me, the struggle is/was that you were insisting on this highly illogical process without explanation why. I'm more than happy to help people do something that seems "right" to me. If you had said early on that you were able to deploy the pdf file via the installer, but were then struggling with how to access that file from your code, this thread would have probably been much shorter and your issue resolved sooner.

    One thing to keep in mind is that, as someone who seems to be new to programming, the solution you come up with for a problem might not be ideal. When you encounter a problem and come up with your own solution, you can create a new thread here in two ways:

    1. You can outline the problem you've encountered and the solution you've come up with. Doing it this way the "experts" here can evaluate your solution, and if it is sound, can provide suggestions on how to implement it; and if your solution is less than ideal, they can suggest alternate solutions.

    2. You can simply outline your solution and not mention anything about the underlying problem that the solution is trying to solve. In that case, you are exponentially less likely to get useful advice, because we have no idea what the problem is you are trying to solve, and so we can't determine if your solution is even remotely viable.

    All that being said, I'm glad you got it sorted.

  34. #34

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    124

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by OptionBase1 View Post
    For me, the struggle is/was that you were insisting on this highly illogical process without explanation why. I'm more than happy to help people do something that seems "right" to me. If you had said early on that you were able to deploy the pdf file via the installer, but were then struggling with how to access that file from your code, this thread would have probably been much shorter and your issue resolved sooner.

    One thing to keep in mind is that, as someone who seems to be new to programming, the solution you come up with for a problem might not be ideal. When you encounter a problem and come up with your own solution, you can create a new thread here in two ways:

    1. You can outline the problem you've encountered and the solution you've come up with. Doing it this way the "experts" here can evaluate your solution, and if it is sound, can provide suggestions on how to implement it; and if your solution is less than ideal, they can suggest alternate solutions.

    2. You can simply outline your solution and not mention anything about the underlying problem that the solution is trying to solve. In that case, you are exponentially less likely to get useful advice, because we have no idea what the problem is you are trying to solve, and so we can't determine if your solution is even remotely viable.

    All that being said, I'm glad you got it sorted.
    PS and I would have probably made less people cross with me.

  35. #35
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,882

    Re: Copy File From A Folder to another Folder and open it with a button

    Quote Originally Posted by kobusjhg View Post
    That is ok I understand hat completely. I probably will maybe leave the forum as well and try and solve things on my own.

    The main fact is, I am enjoying this coding thing very much an is still going to teach myself even though I am already 64 Years old.
    Please continue to post your questions here.

    Edit: Yes, as clarified by techgnome, I mean, please continue to post your questions here on this website. Sorry for being abrasive. Much joy can be found in writing code that works!
    Last edited by OptionBase1; Sep 22nd, 2023 at 03:36 PM.

  36. #36
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,375

    Re: [RESOLVED] Copy File From A Folder to another Folder and open it with a button

    By "here" he means VBForums... not "here" as in this thread ... unless it's directly related to the topic, then that's fine, but if it's a new question/problem, give it the respect it deserves and post it in a new thread.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width