none
I need a button that launches my HTML document stored in the Bin/Debug folder of my Project in Visual Studios C# (Windows Application) RRS feed

  • Question

  • I am in desperate need of a button that when clicked launches my HTML document stored in my Bin/Debug Folder of my project. I am using Windows Application (C Sharp).

    Someone said something about "Application StartupPath." Any help would be very much appreciated. 

     



    Tuesday, March 20, 2018 3:21 PM

Answers

All replies

  • For example :

    string sFile = AppDomain.CurrentDomain.BaseDirectory + "Test.html";
    Process.Start(sFile);


    Tuesday, March 20, 2018 4:14 PM
  • //Assumes the document is in the current working directory of your app (which it will be by default)
    Process.Start("test.html");
    Opens the document using the user's default browser.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, March 20, 2018 5:40 PM
    Moderator
  • We assume you don't really want to do that. Do you understand the difference between a Debug build and a Release build? When you make a Release build you won't want to get anything from the Debug directory. Fortunately both current responses will use the Release directory for a Release build.

    An alternative is to store the HTML as a resource in the executable so that the HTML is in the exe file. The details of how to do that (I think) depend on whether the application is a WPF or Windows Forms application. I know I have done it for unmanaged applications and for WPF applications.

    Also, if you need to interact with the HTML then you probably need to load the HTML into a WebBrowser control.



    Sam Hobbs
    SimpleSamples.Info

    Tuesday, March 20, 2018 6:46 PM
  • Hello GeorgeBradlry321,

    >>Someone said something about "Application StartupPath." Any help would be very much appreciated. 

    Application.StartupPath also applies to your requirement, which will return the path for the executable file that started the application. it could works well with relative path. A simple code like below.

               string path=Path.Combine(Application.StartupPath, "..\\..\\Form1.cs");
    
                FileInfo fs = new FileInfo(path);

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 21, 2018 5:39 AM
    Moderator
  •  This launched my HTML document just the way I needed it. Thank you very much indeed, you're a real lifesaver!
    Wednesday, March 21, 2018 1:38 PM