开发者

embedding web site in c# project

开发者 https://www.devze.com 2023-02-10 12:17 出处:网络
I am currently 开发者_StackOverflow社区developing a C# application. I want to have a website as a help file that is loaded within the Windows form of the software.

I am currently 开发者_StackOverflow社区developing a C# application. I want to have a website as a help file that is loaded within the Windows form of the software.

I have added the directory where the help site is stored inside with the rest of the project classes and folders and included it into the project.

I have the following in the code

string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
string openPath = Path.Combine(appPath, "HelpFiles/Introduction/index.htm");
helpContent.Navigate(openPath);

How can I reference the site directory from inside the main project. At the moment I can only get it to work if I can copy the directory into the bin/debug directory where the exe is located. I don't want this I want the HelpFiles directory to be embedded into the main part of the software.


How are you planning to deploy your project? If you are planning to use VS Setup project then you should mark your help files as content files and then in setup project, place the content files at installation directory - for example, you may choose structure such as:

<Installation Dir>
   bin -> place project output here
   help -> place project content files

Now you can use a relative path from app base path i.e.

string openPath = Path.Combine(appPath, "../help/Introduction/index.htm");

Another way could be to mark all your help files as "copy to output" (from files property), that will put all your files in the same directory as exe.

0

精彩评论

暂无评论...
验证码 换一张
取 消