Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: Dynamicly adding files and folders

$
0
0
Hi,

First of all nice work!

In my case my msi contains 2 parts,
Part 1: is generated from VS and is static so coding this part was easy.
Part 2: This is generated from external tools and sources and is dynamic meaning the the code i a writing should scan files and folders and add them automaticly to the MSI. and there is a catch

There are files in different folders with the same name.

Any help is welcome even tips or ... because for the moment i am goiing crazy in trying different steps ...
Dir RootFolder = new Dir(_InstallDir);
System.IO.FileInfo[] files = null;
System.IO.DirectoryInfo[] subDirs = null;
if (files != null)
{
foreach (System.IO.FileInfo fi in files)
{
RootFolder.AddFile(new File(GenerateRandomID(), fi.FullName));
}
}
subDirs = rootfolder.GetDirectories();
foreach (System.IO.DirectoryInfo dirInfo in subDirs)
{
RootFolder.AddDir (ScanSubFolder(dirInfo));
}
_MSIFile.AddDir(RootFolder);

        private Dir ScanSubFolder(System.IO.DirectoryInfo sourceFolder)
        {
            Dir WixDir = new Dir(sourceFolder.Name);
            System.IO.DirectoryInfo[] subdirs = null;
            System.IO.FileInfo[] files = null;

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    WixDir.AddFile(new File(fi.FullName));
                }
            }

            subdirs = sourceFolder.GetDirectories();

            foreach (System.IO.DirectoryInfo dirInfo in subdirs)
            {
                WixDir.AddDir(ScanSubFolder(dirInfo));
            }

            return WixDir;
        }
Using the above code to scan the files and folders is not going as planned it generates some folders but all empty. folder structure is added some folders are created some not

Viewing all articles
Browse latest Browse all 1354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>