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

OpenFolderPickerAsync throws ArgumentException when selecting a recently deleted folder #17908

Open
KThompson-Lane-Unity opened this issue Jan 7, 2025 · 0 comments
Labels

Comments

@KThompson-Lane-Unity
Copy link

Describe the bug

When using the folder picker if you attempt to select a folder which you have deleted using the picker window, it will allow you to choose that folder even though it no longer exists, but then throws an unhandled ArgumentException causing the application to crash.

To Reproduce

  1. Open folder picker window using OpenFolderPickerAsync
  2. Select an existing folder or create a new one using the picker window
  3. Delete the folder
  4. Click Select Folder

Expected behavior

  • A dialog message is shown stating that the path does not exist

Avalonia version

11.2.0

OS

Windows

Additional context

OpenFilePickerAsync behaves similarly, but instead of throwing an exception it just silently fails to return a file. Which is also inconsistent with what happens when you try to add a file which does not exist.
Dialog window which shows in the latter but not in the former:
expected behaviour

Stack trace excerpt:

System.ArgumentException: Directory must exist (Parameter 'fileSystemInfo')
   at Avalonia.Platform.Storage.FileIO.BclStorageItem..ctor(FileSystemInfo fileSystemInfo)
   at Avalonia.Platform.Storage.FileIO.BclStorageFolder..ctor(DirectoryInfo directoryInfo)
   at Avalonia.Win32.Win32StorageProvider.<>c.<OpenFolderPickerAsync>b__10_0(String f)
   at Avalonia.Win32.Win32StorageProvider.<>c__DisplayClass13_0`1.<ShowFilePicker>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Avalonia.Win32.Win32StorageProvider.OpenFolderPickerAsync(FolderPickerOpenOptions options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant