Strange String Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I read a string hPath from a global class (hPath = g.helpPath), the
watch says hPath = "C:\Help\SusanHelp". When I get the NameSpace from the
HelpProvider on the form (strNameSpace = hpHelp.NameSpace), the watch on
strNameSpace = "C:\\Help\\SusanHelp". Why are the watches different? The
problem arrises when I append a url (ex. "Cats/Gorbash.htm") to strNameSpace
and send this path to the AxWebBrowser, I get an error. This does not occur
when I append the url to hPath and send it to AxWebBrowser. I need to use
strNameSpace. Any ideas on how to fix this?

Thank you,
Susan
 
Susan said:
When I read a string hPath from a global class (hPath = g.helpPath), the
watch says hPath = "C:\Help\SusanHelp". When I get the NameSpace from the
HelpProvider on the form (strNameSpace = hpHelp.NameSpace), the watch on
strNameSpace = "C:\\Help\\SusanHelp". Why are the watches different? The
problem arrises when I append a url (ex. "Cats/Gorbash.htm") to strNameSpace
and send this path to the AxWebBrowser, I get an error. This does not occur
when I append the url to hPath and send it to AxWebBrowser. I need to use
strNameSpace. Any ideas on how to fix this?

I'd ignore what the watch says and write the value out to a log file or
something similar if you really want to know what's going on.

The rest of your problem sounds very odd though. Could you post a short
but complete program which demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Here's my code (it's in the listbox SelectedIndexChanged event):

(Please excuse any typos. I can't cut and paste.)
XmlDocument doc = new XmlDocument();
XmlNode xNode;
\\NameSpace = HelpProvider.NameSpace
doc.Load(NameSpace + "WebHelp\\" + iPath);

XmlElement root = doc.DocumentElement;
int x = lstbbResults.SelectedIndex;
string tmp = lstbResults.Items[x].ToString();
tmp = tmp.TrimStart(null);

xNode = root.SelectSingleNode(descendant::topic[@name='" + tmp + "']");

XmlAttributeCollection attrColl = xNode.Attributes;

//here's where it starts getting wierd
string filePath = NameSpace + "WebHelp\\";
filePath = filePath + attrColl["url"].Value.ToString();

//hPath = the same as NameSpace, but is gotten from a Globals class
string filePath2 = hPath + attrColl["url"].Value.ToString();

//this one does not display the file
if (File.Exists(filePath))
{
axWebBrowser.Navigate(filePath, blah, blah, blah);
}

//this one displays the file
if (File.Exists(filePath2))
{
//ctrlTemp is a user control with an AxWebBrowser
axWebBrowser.Navigate(filePath2, blah, blah, blah);
}

Thanks for your help.
Susan
 
Jon Skeet said:
Why not, out of interest?

I post on the newsgroups at home, but all my code is at work. :)

Here's the code:
//GlobalClass is just a class with global variables like where the help
files are stored
GlobalClass g = new GlobalClass();
string hPath = g.HelpPath //=c:\bob\help
string path = helpprovider.namespace //=c:\\bob\\help

Is that what you needed? I have fixxed the problem by doing a replace, but
was still curious why one works without it while the other doesn't.

Thanks again!
Susan
 
Susan said:
I post on the newsgroups at home, but all my code is at work. :)

That shouldn't make a difference when it comes to short but complete
examples though - short programs are usually short enough that you can
type them up at home :)
Here's the code:
//GlobalClass is just a class with global variables like where the help
files are stored
GlobalClass g = new GlobalClass();
string hPath = g.HelpPath //=c:\bob\help
string path = helpprovider.namespace //=c:\\bob\\help

So if you print hPath and path to the console, do they look the same or
different?
Is that what you needed? I have fixxed the problem by doing a replace, but
was still curious why one works without it while the other doesn't.

No, I need a *complete* program - one that I can run and see the same
problem that you do.
 
Back
Top