diff --git a/SystemTools.cxx b/SystemTools.cxx
index 99256406478757a2ef44297745431a2d6e21ad10..760e529c9482944d0532abcb8f97658dfb0961b7 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -630,6 +630,7 @@ bool SystemTools::MakeDirectory(const char* path)
     Mkdir(topdir.c_str());
     pos++;
     }
+  topdir = dir;
   if(Mkdir(topdir.c_str()) != 0)
     {
     // There is a bug in the Borland Run time library which makes MKDIR