Relative path

I have a windows project. In the current directory, I have a help folder with * .chm files. What is the easiest way to run them from an application? How to indicate the relative path to them?

+5
source share
4 answers

You should use Help.ShowHelp for this

var chmFile = "CHM/test.chm";
Help.ShowHelp(ctrl, chmFile);

by default ShowHelp will search for the file in the application path

+5
source

The Environment.CurrentDirectory property will be set to the location of your .exe file. Therefore, if you place your help folder, it will be:

// The path to the Help folder.
string directory = Path.Combine(Environment.CurrentDirectory, "Help"); 

// The path to the Help file.
string filePath = Path.Combine(directory , "myHelpFile.chm"); 

// Launch the Help file.
Process.Start(filePath); 

EDIT: , Environment.CurrentDirectory , Windows Forms, (, OpenFileDialog - . ) . Windows Environment.CurrentDirectory %SystemDirectory%.

+6

Process.Start("myHelpFile.chm");

chm , .

, chm , exe. help, @"Help\myHelpFile.chm".

+3

, , . , ( ), (, ):

:

var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

:

var path = System.Environment.CurrentDirectory;

, , gets the path for the executable file that started the application, not including the executable name:

var path = Application.StartupPath;

, .

+2

All Articles