How should I Restore My Local storage data when I migrate from UWP to WinUI UnPackaged app MAUI?
See the question and my original answer on StackOverflowAny 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.