Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

For some reason the following code sets the value of path as @"\Themes\Default\Image.jpg". Am I doing something stupid, does the .Net Compact Framework have bugs or what?

string path = System.IO.Path.Combine(@"\Program Files\Selection", @"\Themes\Default\Image.jpg");

Anybody looking for a graduate programmer (Midlands, England)?
Posted

I've managed to solve the problem myself, but I'll post the solution incase anyone else meets this problem.

 

From MSDN...

If path2 does not include a root (for example, if path2 does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If path2 includes a root, path2 is returned.

The bold section is the key to this problem, unfortunately on mobile devices the root is the same as the seperator character. As such you have to remove any seperator characters that appear at the start of path2 before combining them.

Anybody looking for a graduate programmer (Midlands, England)?
Posted
The code returns path2 in the full .Net Framework aswell so you are probably correct. I personally can't see a reason why a preceeding seperator character would cause any specific problems, I guess its just down to standards.
Anybody looking for a graduate programmer (Midlands, England)?

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...