How to add data file to Windows Universal app - c#

I am working on a Universal app, initially targeting Windows Phone 8.1.
I have an XML file that I would like to package/ship along with the app, which the app will read when it's being run and will also update it.
I've found examples of how to read and save to a local folder but nothing about how to ship data along with the app and read it.
Should the XML file be added as a resource? Or should it be stored in the local folder? If so, how do I add the file to that folder ahead of time? In a previous app I added XML files as resources, however that app was for Windows Phone 8 and the Universal apps seem to have changed how a lot of things are done so I am not sure what the best option is here.
What's the best way to do this?
Thanks!

The only way to ship data with the app is to include it in appx package by adding it to your project and marking it as content. This will place it in the app's read-only install directory.
To update the file you'll need to copy it to the application data folders. I'd probably write an access function to get the file which loads it from the local folder if it exists there. If not, then copy it over.
--Rob

Related

MSIX c# - Update and deploy on server/OneDrive

Goal:
I am trying to make a setup file for my app. Futhermore the app must be able to be updated from a server or OneDrive.
Solution:
I am using windows application packaging project for this.
The issue:
The installer works fine when the installer location is on my local harddrive. But when i try to change the installer location to my online file manager or a public OneDrive folder I am unable to download and install the update or App for that matter.
My question:
Has anyone been able to use windows application packaging project where the app downloads updates from a server / OneDrive by uploading the installation file to a server / OneDrive and entering the path to the location, or am I on the wrong track?
Alternatives
The alternativ is of course to use Setup Project and perhaps AutoUpdaterDotNET (from NuGet) which works fine, but now I am interested in a solution which does not require several different third-party programs, and windows application packaging project seems to be the solution.
Have you tried creating an .appinstaller file? This XML file (which you can write in any code editor - you don't need VS or Advanced Installer to generate it, although that way is easier) should allow the OS to cache all the necessary information to auto-update the app accordingly.

Where can I store my config file using windows forms?

I'm fairly new to windows forms and I was recently tasked with creating a simple software which will be deployed by USB drives to other companies. I made this software so during first run I check for a config.xml file. If it doesn't exist, I will send the user to a form to configure their first time setup. Next time I run the program, it skips this step since the config.xml file is found with its values. The problem is when I debugged this, I found the config.xml file alongside the executable, however when I ran this on a different computer, it stored it into the appdata virtual store. I read up on this and found out it has to do with write permissions.
Is there any way I can get around this without prompting the user to do anything extra on their part such as run as administrator? I also plan on saving the resulting reports generated by the use of this program and was hoping I can have XML files which can be easily found within the application folder.
*Note, I am aware of the built-in settings system but this also stores into appdata and if the executable is moved to another directly, it loses sight of that config and wants to create another.
EDIT : Please be aware I am trying to AVOID writing to the AppData folder. The software is packaged with Visual Studio Installer - Setup Project. A msi file is created which stores the application in C:\Program Files (x86)\\. Inside this directory I have the executable, the exe.config file which is generated, and any DLLs needed. This is the folder I am trying to also store the config.xml file but due to some windows magic, the code thinks its storing it here but in reality it is being stored in the virtualStore folder located in AppData.
Have you thought of using the C:\ most computers have this unlocked. alternitively use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
the AppData folder is stored in the username space and requires no permission. (just remember to create a folder for your program to avoid conflicts)
It is a known issue due to security concerns that write permissions are limited.
More can be learned here.
Since no one was able to answer this, I will post my solution. Instead of packaging the solution using Visual Studio Installer tools. I install the application by copying the resulting executable from the build. This version of the application has write permissions that would have not existed if the application was installed using the resulting .msi from the Installer tools.

Access dynamic file in .NET CORE 2

I'm trying to figure out a way to deploy .NET Core project containing files that are acting as data storage. I'm using .csv files. I will be modifying these files, both manually and programmatically. This project could potentially be deployed to Windows, Linux, and Mac, so I don't know where these files should be located. I've attempted to make them embedded resources and access them via scoping to the assembly, but any changes to these files don't seem to be represented when accessing this way.
How would I go about achieving what I want?
The location to store data files like that varies between systems. For the most part, you're supposed to use environment variables to store data in a subfolder of the appdata folder on Windows or a subfolder of a user's home directory on Linux. (And probably OS X too, though I don't know that one)
Alternatively, you can write a program that is "portable" or doesn't need to be installed to run, and you can store your data files in the same folder your application is run from.

MetroLog does not working after install appx file in windows phone 10

I've install the MetroLog package from Nuget into UWP solution (VS2015).
In debug mode everything works fine -
it create a log file in local folder and write contents inside.
When i create an .appx file, copy it into the WP device and install it,
nothing happend, the MetroLog does not create any log file.
Please, need help?
MetroLog is supported in UWP. And by default, in will store logs in the app's LocalState folder. So the key point here is how to access LocalState (LocalFolder) folder in Windows 10 Mobile.
Usually, we may use some third party tools like IsoStoreSpy or Windows Phone Power Tools to access Isolated Storage. With these tools, we can access LocalFolder, TemporaryFolder and RoamingFolder. However, these two tools can only works when the application is deployed in Debug mode.
For now, it is suggested to use App File Explorer to view and manipulate files stored by your sideloaded apps. This tool should be able to work no matter your application is deployed in Debug mode or Release mode. But please note that this is a new tool added to Windows Device Portal in the Anniversary Update.
To use this feature, we need enable Device discovery and Device Portal. For more info, please see Using the App File Explorer to see your app data.

Using .NET 4.5 C# to create a .exe file then write code to it in c# then open it

Hi i would like to know if i can write code into a File.Create(Directory.GetCurrentDirectory() + "/Name.exe") that is in c#.
My purpose for this is I need 2 applications, one is a launcher and one is a updater, i originaly had a File.Exist looking for the updater so no errors occured, but i would like it so you only need the launcher at first then it adds the other folders and files when you first open it.
Instead of reinventing the wheel try using ClickOnce
If you're going to need a certificate if your app is to be signed and publicly distributed. You can work with a test certificate for development
Build your app, right-click on the main project and pick Publish (also on the Build menu), follow the wizard
The target location you pick will end up having an app.application file and some folders, one for each version you publish. You can put these files on a file server somewhere and share the link to the .application file with your users. Every time you publish their app will get updated the next time they use it.
If reinventing the wheel is your thing you can build your app, make another project checks a link for a file that contains a version, compares with the local version and downloads if newer, then launches the downloaded exe.... just like clickonce

Categories

Resources