Combining a DirectoryInfo and a FileInfo path
.net
Solution
If absoluteDir and relativeFile exist for the sole purpose of being used to create absoluteFile, use should probably stick with plain strings for them and leaving only absoluteFile as a FileInfo.
var absoluteDir = @"c:\dir";
var relativeFile = @"subdir\file";
var absoluteFile = new FileInfo(Path.Combine(absoluteDir, relativeFile));
Edit: If otherwise you really need them to be typed, then you should use Path.Combine applied to the OriginalPath of each of them, which you can access such as in:
var absoluteDir = new DirectoryInfo(@"c:\dir");
var relativeFile = new FileInfo(@"subdir\file");
var absoluteFile = new FileInfo(Path.Combine(absoluteDir.ToString(), relativeFile.ToString()));
The OriginalPath property can not be access directly because of the "protected" statuts.
Problem
If I have an absolute DirectoryInfo path and a relative FileInfo path, how can I combine them into an absolute FileInfo path? For example: ``` var absoluteDir = new DirectoryInfo(@"c:\dir"); var relativeFile = new FileInfo(@"subdir\file"); var absoluteFile = new FileInfo(absoluteDir, relativeFile); //-> How to get this done? ```