diff --git a/SystemTools.cxx b/SystemTools.cxx
index b03ad1ff22c9438c80244c12ab746a7e1cf02dff..274e33351c36b0b647816220ead7a85a6dd3d9de 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3466,7 +3466,7 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
   do
     {
     path = SystemTools::GetParentDirectory(path.c_str());
-    if ( dir == path )
+    if(SystemTools::ComparePath(dir.c_str(), path.c_str()))
       {
       return true;
       }