Cags Posted April 22, 2006 Posted April 22, 2006 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"); Quote Anybody looking for a graduate programmer (Midlands, England)?
Cags Posted April 22, 2006 Author Posted April 22, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
Leaders snarfblam Posted April 22, 2006 Leaders Posted April 22, 2006 I think that in general (at least, as far as the .Net framework is involved) a relative folder path should not start with a backslash. Quote [sIGPIC]e[/sIGPIC]
Cags Posted April 22, 2006 Author Posted April 22, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.