By a full name of this file. :-)
This is ugly and simply won't work. If this is some
C:/myHtmlFile.html
on some systems there is no such thing as "
C:
" (believe or not). On Windows 7 you will have trouble putting the file in this directory.
You should really never use hard-code absolute path in any applications. You cannot also make any assumption about the working directory: it depends on how the user starts the application and can be different every time.
The path should always be calculated during run-time. If the file is not modified during run-time, you can put in in the executable directory or a relative path relative to this directory. This is how to find it:
string exeDir = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetEntryAssembly().Location;
Warning! There are different ways to do that — they are less universal and may depends on how the assembly is hosted or where the other assemblies are. This method always returns the location of main executable module of the entry assembly of your application (normally, this is EXE file).
Now, if your file is read-write, you should use a special path where your files can be accessed. Use
System.Environment.GetFolderPath(System.Environment.SpecialFolder)
, typically with
System.Environment.SpecialFolder.LocalApplicationData
.
See
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx[
^],
http://msdn.microsoft.com/en-us/library/14tx8hby.aspx[
^].
—SA