Problem Statement
We were working on a Digital Signage application, where we have used the Universal Windows Platform (UWP). The application heavily depends on the data files, i.e., the quality images and videos and their effective navigation is key in this application. The total size of the data files is very huge (more than 25 GB). We can not package this app as there is a restriction on the Package Size that it can be 25 GB maximum per bundle.
In this article, I will be sharing how we shipped this application which had huge data.
Prerequisites
- Familiarity with creating Universal Windows Platform (UWP) applications
- Familiarity with Application Design
Load data through the external device
We solved this particular problem by separating application package from its data. By doing this, we reduced the application package size to be as small as possible. Data is shipped separately via an external device, for example, USB. We added the required logic to make the application smart by detecting external drive when inserted and copied the same data into the local machine.
Steps:
- Keep the Application Package as light as possible and separate this from data files
- Data files need to be shipped separately in the form of USB
- As and when the Application is installed and started for the first time, it checks for the data folder. As it is running for the first time, it will not find data. Depending on the configuration, the installer prompts the user to insert a drive consisting of the data files.
Code:
Please find the code logic for detecting external storage and copying data into the AppData folder as mentioned below. At the start of the Application, we’ll verify to check whether data is available locally or not. If not, we try reading it from external storage (App.xaml.cs).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
/// <summary> /// Invoked when the application is launched normally by the end user. /// Other entry points /// will be used such as when the application is launched to /// open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #region System-Generated-Code #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the // Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate // to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if(e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } #endregion if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate // to the first page, // configuring the new page by passing required information // as a navigation parameter bool IsDataLoadedFromUSB = false; if (!await new StorageManager().IsDataAvailable()) { await new USBManager().SetUpAppDataFromExternalStorrage(); IsDataLoadedFromUSB = true; } rootFrame.Navigate(typeof(MainPage), IsDataLoadedFromUSB); } // Ensure the current window is active Window.Current.Activate(); } } |
Summary
This article explained how to package Universal Windows Platform (UWP) Application whose data size is > 25GB. I hope this article guides you in taking an informed decision.
At WalkingTree, we are excited about UWP’s ability to enable developers to build the app which runs on windows-based devices of different sizes. We continue to take advantage of this and love to help you as well.