0

so I have migrated my Xamarin app to MAUI. that means from UWP to WinUI in Windows. I was using Windows.Storage API Which works fine in Packagedapps (MSIX). However, shipping the app outside of the MS Store in that format is quite annoying (specifically the signing and sideloading.) Every user has to first trust my self-signed certificate and then install the app.

I would like to publish the app as an unpackaged version, but the Windows.Storage API is not supported in unpackaged apps due to package identity missing. So I can change it to System.IO.File

But already many users are using our app. So there might me data loss when I shift from windows.storage to system.IO.FIle . Is there any way I Can restore those old data stored using Windows.Storage?

As location path of windows.Storage and System.IO.File is different. I have no idea how to get back the information stored using windows.Storage as it is important data. Please suggests any ideal solution for this.

3
  • Any app can still use Windows.Storage API but obviously it won't be able to use methods related to packaging (like Windows.ApplicationModel.AppInfo, Windows.ApplicationModel.Package, ApplicationData.Current.LocalFolder, etc.). From an unpackage app you can get the equivalent of ApplicationData.Current.LocalFolder, with Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Packages", MyOldPackageFamilyName, "LocalState") if it's what you're looking for. Commented Mar 14, 2024 at 9:45
  • @SimonMourier thankyou for your comment .can you please help me with what should I replace MyOldPackageFamilyName Commented Mar 15, 2024 at 14:26
  • Should be Windows.ApplicationModel.AppInfo.Current.PackageFamilyName from your packaged/UWP version. Commented Mar 15, 2024 at 14:33

1 Answer 1

0

Any Windows app can still use Windows.Storage API (StorageFolder, StorageFile, etc.) but obviously, if it's not packaged, it won't be able to use methods related to packaging (like Windows.ApplicationModel.AppInfo, Windows.ApplicationModel.Package, ApplicationData.Current.LocalFolder, etc.).

So, from an unpackaged app that was previously packaged, you can keep most of your Windows.Storage API based code. The equivalent of

ApplicationData.Current.LocalFolder

can be replaced by something like

Path.Combine(       
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData,
    "Packages",
    myOldPackageFamilyName,
    "LocalState")

with myOldPackageFamilyName being the value of Windows.ApplicationModel.AppInfo.Current.PackageFamilyName from the packaged version.

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

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.