0

I have the following problem. I have a packages winui program which should open a CANoe config when a button is pressed. Behind this CANoe config there are other SubFolder/Files which are also needed.

So that I don't have to put these files on a network drive, I wanted the tool to store these files locally on the respective computer during installation and always open them from there.

Example folder structure which should be copied locally

  • Folder 1
    • Subfolder 1
      • files
    • Subfolder 2
      • files
    • Subfolder 3
      • files

How do I ensure that this folder structure is copied to the following path of my computer during installation via the msxi bundle?

AppData\Local\Packages\{your app's ID}\temp\Folder 1

...........................................

2 Answers 2

0

There is no way to copy this folder structure to the specified path of the computer during installation via the MSIX bundle.

When you double click the .MSIX (during installation), App Installer launches and provides the basic app information as well as an install button, installation progress bar, and any relevant error messages.

Sign up to request clarification or add additional context in comments.

2 Comments

is there any other way? If I added the folder to my msxi bundle with "CopyToOutputDirectory" in my .csproj file. Then the folder should be in the installation path of my app? Can I then copy these files with first startup of my app to the path of my question?
There is no way to realize it. You could manually copy these files into the path after first startup of your app.
0

As an alternative, you can create the folders/files when the app runs.

For example:

  1. Create a "Folder 1" on your project.
  2. Inside "Folder 1", create "Subfolder 1".
  3. Inside "Subfolder 1", create a "TextFile1.txt" file.
  4. Set "TextFile1.txt"'s Build Action to Content.
  5. Implement the next code in App.xaml.cs:
public partial class App : Application
{
    private Window _window;

    public App()
    {
        this.InitializeComponent();
    }

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        await CreateAppFolders();
        _window = new MainWindow();
        _window.Activate();
    }

    private static async Task CreateAppFolders()
    {
        StorageFolder temporaryFolder = ApplicationData.Current.TemporaryFolder;
        IReadOnlyList<StorageFolder> temporaryFolderSubFolders = await temporaryFolder.GetFoldersAsync();

        // Returns if "Folder 1" already exists.
        if (temporaryFolderSubFolders.FirstOrDefault(folder => folder.Name == "Folder 1") is StorageFolder folder1)
        {
            return;
        }

        System.Diagnostics.Debug.WriteLine($"Creating 'Folder 1' and its subfolders on {temporaryFolder.Path}");

        folder1 = await temporaryFolder.CreateFolderAsync("Folder 1", CreationCollisionOption.OpenIfExists);

        StorageFolder subFolder1 = await folder1.CreateFolderAsync("SubFolder 1", CreationCollisionOption.OpenIfExists);
        StorageFile textFile1 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Folder 1/SubFolder 1/TextFile1.txt"));
        await textFile1.CopyAsync(subFolder1, "TextFile1.txt", NameCollisionOption.ReplaceExisting);

        StorageFolder subFolder2 = await folder1.CreateFolderAsync("SubFolder 2", CreationCollisionOption.OpenIfExists);
        StorageFolder subFolder3 = await folder1.CreateFolderAsync("SubFolder 3", CreationCollisionOption.OpenIfExists);
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.