Problem accessing folders in application

amthekkel

Member
Joined
Mar 26, 2009
Messages
14
Programming Experience
Beginner
Hi all,

i have an application for which i have created help files which are html files. my application resides in a directory for which the system path comes out as

c:\Document and settings\visual studio 2005\crms\crms\bin\debug\crms.exe

I have the help files put under the crms directory which has the bin as its sub directory.

i.e. c:\Document and settings\visual studio 2005\crms\crms\help\main.html

In my application i would like to access this file and launch it in Internet Explorer. I dont want to hard code it as this will be deployed on a terminal server and therefore i would like to use a relative path. I searched on the net and could only find solutions that used Application.StartupPath or few others which point to the exe file.

I tried extracting the path before that and managed to get a substring which held contained c:\Document and settings\visual studio 2005\crms\crms\

To this appended the \help\main.html, i tried launching the file as follows

System.Diagnostics.Process.start("iexplore",s);

where s, stores the appended string. This is the error i get, cannot open file at location

c:\Document%and%settings\visual%studio%2005\crms\crms\help\main.html

Its not liking the space in the path, is there anyway to resolve this.

Any suggestion would be much appreciated.

cheers
abhi
 
You could try:

VB.NET:
Process.Start("iexplore", My.Computer.FileSystem.CombinePath(BasePathSubstring, "help/main.html"))

where BasePathSubString is your directory substring part.
 
no joy :(

HI demausdauth

thanks for your reply, I tried the code u suggested but again i am getting the same problem. Each time i user Process.start("iexplore", filepath)

the space in the filepath is being converted to as % sign and the system is unable to find it. I need a way to let the system ignore the space. if i was hardcoding a string then i could have used @" string." , but since i am getting most of the path from function like Computer.Filestystem...or Application.StartupPath etc.

any suggestions?

cheers
abhi
 
Not sure what is going on, can you post some code.

I have tried the following and it works without error.
VB.NET:
   'C:\Documents and Settings\atest\My Documents\Visual Studio 2005\Projects\TestingVBNetForums\TestingVBNetForums\help\main.htm
        'Application.Startup = C:\Documents and Settings\atest\My Documents\Visual Studio 2005\Projects\TestingVBNetForums\TestingVBNetForums\bin\Debug

        Dim StartUp As String = Application.StartupPath()
        StartUp = StartUp.Remove(StartUp.LastIndexOf("\"c), (StartUp.Length - StartUp.LastIndexOf("\"c)))
        StartUp = StartUp.Remove(StartUp.LastIndexOf("\"c), (StartUp.Length - StartUp.LastIndexOf("\"c)))

        Process.Start("iexplore", My.Computer.FileSystem.CombinePath(StartUp, "help\main.htm"))

There is probably a better way to do this, but this is quick and dirty knowing that i need to go up 2 levels.

One I did notice is that here you have an ending backslash

VB.NET:
c:\Document and settings\visual studio 2005\crms\crms\

and here you have a beginning backslash

VB.NET:
\help\main.html

that may or may not be causing an issue.
 
Sorted: was a stupid mistake

Hi demausdauth,

thanks for your reply again.. I manage to sort the issue out, which turned out to be a really annoying one.

the html file i had created "main.html" was using visual studio. I had done add->Component->Html Page. What i didn't realise or notice is that it saved the file as main.html instead of main.html.

so each time i was trying to refer to main.html the application couldn't find it.

Cheers your help.

much appreciated.

abhi
 
Back
Top