Relative path to absolute path in C#?

Assuming you know the real directory the XML file lives in use Path. Combine, e. G var absolute_path = Path.

Combine(directoryXmlLivesIn, "..\images\image. Jpg") If you want to get back the full path with any ..'s collapsed then you can use: Path. GetFullPath((new Uri(absolute_path)).

LocalPath).

Assuming you know the real directory the XML file lives in use Path. Combine, e.g. Var absolute_path = Path. Combine(directoryXmlLivesIn, "..\images\image.

Jpg"); If you want to get back the full path with any ..'s collapsed then you can use: Path. GetFullPath((new Uri(absolute_path)). LocalPath).

Thanks, my problem was apparently that I had forgotten to get the directory of the xml file first, I had tried Combine, but with the absolute path of the file, which didn't work. I don't know which of all these answers was first, the time shows the same, but you pointed out to get the directory, so I chose your answer. Thanks to all though!

– Anders Svensson Jan 25 at 21:04.

You can use Path. Combine with the "base" path, then GetFullPath on the results. String absPathContainingHrefs = GetAbsolutePath(); // Get the "base" path string fullPath = Path.

Combine(absPathContainingHrefs, @"..\..\images\image. Jpg"); fullPath = Path. GetFullPath(fullPath); // Will turn the above into a proper abs path.

Take a look at Path. Combine msdn.microsoft.com/en-us/library/fyy7a5k....

This worked. Var s = Path. Combine(@"C:\some\location", @"..\other\file.

Txt"); s = Path. GetFullPath(s).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions