private MsiDirectory GetSourceFiles(string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            var lstReturn = new MsiDirectory
            {
                RootPath = sourcePath,
                RelativePath = "",
            };

            var dirInfo = new DirectoryInfo(sourcePath);
            var topFiles = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly);
            foreach (var file in topFiles)
            {
                lstReturn.MsiFiles.Add(new MsiFile() {Path = file.FullName});
            }

            foreach (var directory in dirInfo.GetDirectories())
            {
                GetMsiDirectory(lstReturn, directory.FullName);
            }

            //foreach (var sourceFile in sourceFiles)
            //{
            //    if (!string.IsNullOrEmpty(version))
            //    {
            //        if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
            //            sourceFile.Name.ToLower() == "v32.cab" ||
            //            sourceFile.Name.ToLower() == "v64.cab"))
            //        {
            //            continue;
            //        }
            //    }

            //    if (officeClientEdition == OfficeClientEdition.Office32Bit)
            //    {
            //        if (sourceFile.Name.ToLower().Contains(".x64."))
            //        {
            //            continue;
            //        }
            //    }
            //    else
            //    {
            //        if (sourceFile.Name.ToLower().Contains(".x86."))
            //        {
            //            continue;
            //        }
            //    }

            //    lstReturn.Add(sourceFile.FullName);
            //}

            return lstReturn;
        }
    private Dir AddProgramFiles(string rootPath, Dir parentDir, MsiDirectory directory)
    {
        var path = rootPath + @"\" + directory.RelativePath;

        var newDir = new Dir()
        {
            Name = directory.Name
        };

        var fileLength = parentDir.Files.Length;
        var newFileList = new File[fileLength + directory.MsiFiles.Count];
        parentDir.Files.CopyTo(newFileList, 0);

        var startIndex = parentDir.Files.Length;
        foreach (var file in directory.MsiFiles)
        {
            newFileList[startIndex] = new File(file.Path);
            startIndex ++;
        }

        newDir.Files = newFileList;

        foreach (var subDir in directory.MsiDirectories)
        {
            AddProgramFiles(rootPath, newDir, subDir);
        }

        var length = parentDir.Dirs.Length;
        var newList = new Dir[length + 1];
        parentDir.Dirs.CopyTo(newList, 0);
        newList[length] = newDir;
        parentDir.Dirs = newList;

        return newDir; 
    }
        public MsiDirectory GetMsiDirectory(MsiDirectory parent, string directoryPath)
        {
            var msiDir = new MsiDirectory
            {
                RootPath = parent.RootPath
            };
            parent.MsiDirectories.Add(msiDir);

            var dirInfo = new DirectoryInfo(directoryPath);

            var relativePath = Regex.Replace(dirInfo.FullName, "^" + parent.RootPath.Replace(@"\", @"\\"), "", RegexOptions.IgnoreCase);
            msiDir.RelativePath = relativePath;
            msiDir.Name = dirInfo.Name;

             var topFiles = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly);

            foreach (var file in topFiles)
            {
                msiDir.MsiFiles.Add(new MsiFile() { Path = file.FullName });
            }

            foreach (var directory in dirInfo.GetDirectories())
            {
                GetMsiDirectory(msiDir, directory.FullName);
            }

            return msiDir;
        }