Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong path to Environment.SpecialFolder.LocalApplicationData. #5900

Closed
JiuLing-zhang opened this issue Apr 8, 2022 · 7 comments
Closed

Wrong path to Environment.SpecialFolder.LocalApplicationData. #5900

JiuLing-zhang opened this issue Apr 8, 2022 · 7 comments
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@JiuLing-zhang
Copy link

Description

The path I get is inconsistent with the actual.

MauiPathError

Test source code:
LocalApplicationDataPathError.zip

Steps to Reproduce

1.Create MAUI App.
2.Get path using Environment.SpecialFolder.LocalApplicationData enum.
3.Check the path using everything.

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

I was not able test on other platforms

Affected platform versions

Windows SDK 10.0.19041

Did you find any workaround?

No response

Relevant log output

No response

@JiuLing-zhang JiuLing-zhang added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 8, 2022
@XamlTest XamlTest added the s/triaged Issue has been reviewed label Apr 8, 2022
@v-longmin v-longmin added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Apr 8, 2022
@v-longmin
Copy link

Verified the issue on VS 17.2.0 Preview 2.1 [32317.152.main], it's repro. Repro project:
LocalApplicationDataPathError.zip

@v-longmin v-longmin removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Apr 8, 2022
@Redth Redth added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Apr 20, 2022
@Redth Redth added this to the 6.0.300-servicing milestone Apr 20, 2022
@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 5, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 18, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.6.0 Preview 3.0. Repro on Windows 11 with below Project:
5900.zip

@softlion
Copy link
Contributor

Issue verified 10 times, no fix for release in october. MMmmmm...

@bsloehr
Copy link

bsloehr commented May 18, 2024

For anybody migrating an app from XF to MAUI and made use of the LocalApplicationData folder in Android, the work around is mentioned here: #21438

@keegan-gehrig
Copy link

keegan-gehrig commented Jun 24, 2024

Are there any workarounds for getting Windows.System.Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) to work in WinUI and allow files stored in the LocalApplicationData folder to be launched from a .NET MAUI app when this environment variable is giving me the wrong path to the local files? As it stands right now, this bug is just causing my app that I'm working on converting from Xamarin.Forms to MAUI to always get a ". contains an incorrect path." error after selecting a program to open a file stored in this folder with. If no workarounds exist for LaunchFileAsync, then is there any alternative that can be used that's actually able to launch something properly from the LocalApplicationData folder (for WinUI specifically)?

Edit:
I ended up finding my own workaround for the WinUI issue. It seems like this should work for what I need specifically, and hopefully it can provide some assistance to others as well. If there's anything wrong with this method, please let me know, but this does seem pretty safe from what I've tested so far:

var localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var localAppDataFullPath = $"{localAppDataPath}\\Packages\\{Windows.ApplicationModel.Package.Current.Id.FamilyName}\\LocalCache\\Local"; if (!filepath.Contains(localAppDataFullPath)) filepath = filepath.Replace(localAppDataPath, localAppDataFullPath); var file = await StorageFile.GetFileFromPathAsync(filepath); var launcherOptions = new LauncherOptions { DisplayApplicationPicker = true, }; await Windows.System.Launcher.LaunchFileAsync(file, launcherOptions);

@jfversluis
Copy link
Member

I think this has to do with a packaged app vs unpackaged app. We have taken that into account in the FileSystem APIs. Otherwise, I don't think this is something we control, but rather something in WinUI or the .NET runtime even.

Thanks for all the input here!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants