1

I'm using MS Visual Studio Pro 2012 and I want to create some kind of help file.

I was thinking in create a html file like this but my question is: Do I need to have the html file always in this directory, even after I have the .EXE file created or the html file is added to the .EXE file?

If not, how can it be done?

[.NET Framework 4.5 | Windows Forms]

EDIT : I want to load a given (local) html file in the default web browser. This file should be 'inside' the .EXE file.

Community
  • 1
  • 1
mafap
  • 371
  • 3
  • 18
  • 40
  • It is probably a good idea to include which versions of what (Visual studio, C#, .NET, Windows) you are targeting. – Tormod Aug 28 '13 at 12:59

4 Answers4

1

If you're looking to build a help file from Visual Studio, why not look at:

http://shfb.codeplex.com/

Sandcastle will build your help file based on the comments you have written on your classes and methods. Hit the forward slash three times (e.g. /) above your class or method declaration and the comment box will appear. Populate with salient details, run Sandcastle, and your help file will be generated.

Mister Epic
  • 16,295
  • 13
  • 76
  • 147
  • 3
    Sandcastle's a useful tool, but it's unlikely that Sandcastle-generated help will be of any use to the end-user of a product - unless the product is an API. – Dan Puzey Aug 28 '13 at 13:20
  • Sorry, I was dead tired when I read the question and completely misunderstood the ask. – Mister Epic Aug 28 '13 at 23:06
1

The advantage of having a separate HTML file is that you can update it on it's own without pushing out a new assembly. However if you want to build it into the EXE, you can go to your project properties, then click on Resources. Add an existing file (your HTML file) and it will now be accessible from your code.

When you want to open it you can do something like this

string html = Resources.MyHelpFile;
if (!File.Exists("tmpHelp.html"))
{
   using (var tmpFile = File.CreateText("tmpHelp.html"))
   {
      tmpFile.Write(html);
   }
}

Process.Start("tmpHelp.html");

You can then delete the help file at a later stage such as when the user closes your application.

keyboardP
  • 68,824
  • 13
  • 156
  • 205
  • In your last paragraph, do you mean close the window/tab of my browser when the application is closed? Can you explain how to do that? – mafap Aug 28 '13 at 13:21
  • No, I just mean when your main application is closed as you probably don't want to keep writing the same HTML file everytime the user opens help. You can handle the FormClosing event or the [ApplicationExit](http://msdn.microsoft.com/en-us/library/system.windows.forms.application.applicationexit.aspx) event. – keyboardP Aug 28 '13 at 13:24
  • This tells me that the names 'Resources' and 'Process' does not exist in the current context. I have my html file in 'Resources', now I just want to open it. – mafap Aug 31 '13 at 12:02
  • You need to import the namespace for `Process`. At the top of your code, add `using System.Diagnostics;` – keyboardP Aug 31 '13 at 13:42
  • This solved the `Process` issue. Should I add something similar to `Resources`? In your code example are you writing to the html file? I just want to read a given file... – mafap Aug 31 '13 at 13:55
  • Resources should've come up on its own if it's in the same namespace but try `MyNamespace.Properties.Resources` (replacing `MyNamespace` with your namespace) instead of just `Resources`. I am writing the HTML file in the example but it's simply copying the given file text. Reason for this is because you can't directly pass the given file string into `Process` so it instead copies the given file into a temporary file which is then launched. – keyboardP Aug 31 '13 at 14:03
  • I can't get this working. Check my edit and tell me please if there any other solution. – mafap Sep 01 '13 at 23:30
1

I'll recommend using HTML Help Workshop to create the help file. and then use Help.ShowHelp();. Its a lot more easier

But for your case. You can either do as KeyboardP suggested or move the file to your bin/Debug folder and then use

    Process.Start("helpname.html");

NOTE : You'll also need to add the file to the Application Folder when you're creating your setup.

1

You can build html file (I think the most easy way it's to create it via microsoft word and to save as html) Then you make a new form contain webBrowser tool and set the URL to your html file path, like this:

string filepath = Environment.CurrentDirectory + @"\Help.htm";
Uri uri = new Uri(filepath);
webBrowser_Help.Navigate(uri);
AsfK
  • 3,328
  • 4
  • 36
  • 73