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

New Post: Maintain directory structure

$
0
0
I figured out the problem with the ID's, the code will be bellow for whoever faces the same issue.
The issue where silent mode requires elevated privileges remains and now I have a new problem. I want to make per-user installations and redirect them to the user datafolder. I haven't been able to find any documentation on this yet.


Fix:
    static void Main(string[] args)
    {
        var dir = PopulateDir("myFolder", true);

        var project = new Project("a_myApp", dir);

        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        project.UI = WUI.WixUI_InstallDir;

        Compiler.PreserveTempFiles = true;
        Compiler.BuildMsi(project);
    }

    static int count = 0;

    private static Dir PopulateDir(string sDir, bool isRoot)
    {
        Dir dir;
        try
        {
            var fileList = System.IO.Directory.GetFiles(sDir);

            var dirList = System.IO.Directory.GetDirectories(sDir);

            WixEntity[] eList = new WixEntity[fileList.Length + dirList.Length];

            for (int i = 0; i < fileList.Length; i++)
            {
                //fileList[i] = System.IO.Path.GetFileName(fileList[i]);
                eList[i] = new File(fileList[i]);
            }
            for (int i = 0, e = fileList.Length; i < dirList.Length; i++, e++)
                eList[e] = PopulateDir(dirList[i], false);
            //string dirname = System.IO.Path.GetDirectoryName(sDir);

            var dirname = new System.IO.DirectoryInfo(sDir).Name;

            if (isRoot)
                dir = new Dir(@"%ProgramFiles%\ACompany\myApp", eList);
            else
                dir = new Dir(dirname, eList);

            if (!isRoot)
                dir.Id = "dir" + count++;
        }
        catch
        {
            return null;
        }

        return dir;
    }

Viewing all articles
Browse latest Browse all 1354

Trending Articles



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