Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
{"Could not find file 'C:\\myStuff\\VS.Net Programming\\C#.Net Programs\\MyProgram\\common run folder\\data.xml'."}

 

           XmlDocument dataXML = new XmlDocument(); 
           string path = Application.StartupPath + @"\data.xml";
           MessageBox.Show(path);
           SkillsXML.Load(path);

 

MessageBox.Show shows it properly with only one backslash, but I get that error about the path not existing/can't find file and it shows double backslashes.

 

I know there are issues with strings and regular expressions in C#, but I thought the @ would remove that problem. Apparently I'm not correct.

 

Anyone know a fix for this?

  • *Experts*
Posted

$10 says the file isn't in that folder, but in your \bin\Debug folder.

You're using Application.StartupPath which points to where the EXE is (or your working directory) which is \bin\Debug by default.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

@Cuffee: Your solution should be the same as his. You can use the @ to NOT have to double up the backslashes or just double them up. I think he had the file in the wrong place. Bad backslashes usually mean syntax errors - but his MessageBox showed the right path (at least, one that looked "good").

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Yeah, I feel stupid. :(

 

I forgot that since I have 3 projects in the solution (the app, a control and a .dll/logic tier), I made a fourth folder for the output of all three when they build. I had put the .xml file inside of the build folder for the application and was thinking my string wasn't working properly.

 

Sorry for the stupid mistake, still getting used to C#.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...