0

I'm currently programming an app that need to access to some Excel files.

So what I need is to create a folder in the app files with these Excel files in it but I want that folder to be created at the app install, so they would be accessible for every device that install the app. The files also need to be modifiable in the future by the user.

The problem is that I don't know how to do it right. Should I just create a new folder in the Solution Explorer and put the Excel files in it ? Should I create the folder programmatically and force the user to put them manually in that folder ?

I don't really know how to do it so that the application will not be too complicated to be modified by the user.

EDIT : Also, if I put the files in the Assets, will the user be able to change them later ?

Reaperino
  • 145
  • 8
  • How do you install your app? – vasily.sib Apr 24 '19 at 06:42
  • I will sideload it on some devices, it's a private app that will only be used by some tablets. The app is for a private company. – Reaperino Apr 24 '19 at 07:31
  • I'm not an UWP expert, but I think [this link](https://learn.microsoft.com/en-us/windows/uwp/app-resources/) should be helpfull – vasily.sib Apr 24 '19 at 07:39
  • Started to read it but I think it could help yes :) – Reaperino Apr 24 '19 at 07:43
  • 1
    You can just put your Excel file in a folder inside your application project (for example in the Asset folder). Once you create the Appx, it is compressed automatically. Check this: https://stackoverflow.com/questions/48970802/how-to-deploy-a-file-in-uwp @vasily.sib resources? Exactly what I wrote in my answer... – Adriano Apr 24 '19 at 14:12
  • Thx for you answer ! That's what I did in the end to have at least some default values. In the future I will add a "Settings" panel to the app to let the user pick some other Excel files if he wants/needs to. – Reaperino Apr 25 '19 at 06:06

2 Answers2

0

So what I need is to create a folder in the app files with these Excel files in it but I want that folder to be created at the app install, so they would be accessible for every device that install the app. The files also need to be modifiable in the future by the user.

For your requirement, you could use ApplicationData.LocalFolder to store Excel files, LocalFolder has full access permission. LocalFolder exists in the app's sandbox path and will be created after the app is installed.

Also, if I put the files in the Assets, will the user be able to change them later ?

Assets folder exists in Windows.ApplicationModel.Package.Current.InstalledLocation and it is read only that often use to store some static resource. You can't modify the file at run time.

For more details about file access permissions please refer this document.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • That's exactly what I've done, I put some default values in the Assets for the Excel files. At the first launch of the application the user will be prompted to pick a folder with the values and if he don't have them the default values in the Assets will be loaded in the LocalFolder. – Reaperino Apr 25 '19 at 07:30
-1

Forget the installer. It is deprecated and the new apps on Windows are installed over the store. If you want to copy some files (Excel templates), you have to put them in your resources. At startup you can check if there is a folder in your App-Data folder with your files, if you don't find them, you can copy it from your resources. So even if the file is deleted, your app can copy them in the next start.

If you use Windows Forms with .NET, you can check this page: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.application.localuserappdatapath?view=netframework-4.8

If you are writing an UWP-app, check this page: https://learn.microsoft.com/en-us/windows/uwp/design/app-settings/store-and-retrieve-app-data

Adriano
  • 1,743
  • 15
  • 28
  • _"It is deprecated"_ - do you have any proof link? – vasily.sib Apr 24 '19 at 07:22
  • 1
    Also storing files in app resource is a bad idea imho. What if this files a too large? I don't want to load 700Mb `.exe` file to my memory, 650Mb of which will be handy only once for a life-time. – vasily.sib Apr 24 '19 at 07:27
  • @vasily.sib no I don't have a proof link. There is a reason why Microsoft removed the "setup" project from Visual Studio. And there is a reason why you can't distribute your UWP over an installer. You can still use InnoSetup, but self-made installer are exotic tools if you do not have any Visual Studio support anymore. He is speaking about an excel file, I do not think it is a 700MB big file! And if it is 700MB, it could be downloaded. – Adriano Apr 24 '19 at 14:05
  • InnoSetup and Visual Studio Installer projects (WiX is my favorite) are just a fancy facade over [Windows Installer](https://en.wikipedia.org/wiki/Windows_Installer). The only reason why you can't install UWP apps with windows installer is the fact that it is **WINDOWS** installer, while UWP is **WINDOWS PLATFORM** (it runs not only on windows OS). Installer project are now [VS Extension](https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects). You shouldn't say it's deprecated only if you don't know where to find it. – vasily.sib Apr 25 '19 at 02:56