[Mono-dev] Path.Combine bug

Nicolò Chieffo 84yelo3 at gmail.com
Tue Oct 28 22:02:43 EDT 2008


Hello, I'm running ubuntu intrepid, mono version 1.9.2, so maybe it's
already fixed.
It seems that Path.Combine has some problems in this case


DirectoryInfo input = new DirectoryInfo(args[0]);
DirectoryInfo output = new DirectoryInfo(args[1]);
			
foreach (FileInfo file in input.GetFiles("*.*", SearchOption.AllDirectories))
{
	string subDirPath = file.Directory.FullName.Substring(input.FullName.Length);
	Console.WriteLine("subDirPath={0}", subDirPath);

	string fullDirPath = Path.Combine(output.FullName, subDirPath); /*
THE RETURNED VALUE fullDirPath IS WRONG */
	Console.WriteLine("fullDirPath={0}", fullDirPath);
	string fullDirPathCorrect = output.FullName + "/" + subDirPath;
	Console.WriteLine("fullDirPathCorrect={0}", fullDirPathCorrect);
	
	string fullFilePath =  Path.Combine(fullDirPath, file.Name); /* this
call has no problems */
	Console.WriteLine(fullFilePath);
	Console.WriteLine();
}


More information about the Mono-devel-list mailing list