sdk
sdk copied to clipboard
admin folder are listed with `Directory.list()` but `Directory.existsSync` return false on them
Steps to reproduce
On Windows directories that require admin privilege to be accessed are listed with Directory.list() but Directory.existsSync returns false on them
I first encountered this on my AppData, if an admin program created some folders you will see this behavior appear
I think the C:\Windows would reveal the same issue if you haven't clicked the first time you accessed it to give yourself permission to see the content of this folder.
Basically, when I got the issue I checked the folder, and the Windows GUI (explorer) asked me if I wanted to get access, I said yes then the error disappeared. the issue is linked to Windows permission.
Expected results
it's not because it's an admin folder that it doesn't exist. you can not list it and then say it doesn't exist.
Actual results
admin folder are listed but Directory.existsSync return false on them
Code sample
Code sample
var stream = d.list(recursive: true);
var stangeFile = stream.where((e) {
return !e.existsSync();
});
stangeFile.forEach((e) {
print(e.path);
});
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.19045.4529], locale fr-FR)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
[!] Android Studio (not installed)
[✓] VS Code (version 1.90.1)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 3 categories.
Labels: area-vm, type-bug
Summary: The Directory.existsSync method incorrectly returns false for directories that require administrator privileges on Windows, even though the directories are listed by Directory.list. This issue is likely related to Windows permissions and occurs when accessing directories like AppData or C:\Windows.
//c @brianquinlan @aam