You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Bug: SaveFileDialog crashes when current working directory is deleted/unmounted at runtime
2
+
3
+
## Summary
4
+
On Linux (GTK/Eto), NAPS2 can throw an unhandled `System.IO.FileNotFoundException` when opening **Save Images** if the process current working directory becomes invalid after startup (for example, removable media unmounted or directory removed).
5
+
6
+
The dialog never opens and users may be unable to save scanned pages.
7
+
8
+
## Affected area
9
+
-`NAPS2.Lib/EtoForms/EtoDialogHelper.cs`
10
+
- GTK `SaveFileDialog` / `OpenFileDialog` construction path
11
+
12
+
## Observed stack trace
13
+
```text
14
+
System.IO.FileNotFoundException: Unable to find the specified file.
15
+
at string Interop+Sys.GetCwd()
16
+
at string Environment.get_CurrentDirectoryCore()
17
+
at string Environment.get_CurrentDirectory()
18
+
at string System.IO.Directory.GetCurrentDirectory()
19
+
at new Eto.GtkSharp.Forms.SaveFileDialogHandler()
20
+
at bool NAPS2.EtoForms.EtoDialogHelper.PromptToSaveImage(...)
21
+
at async Task<bool> NAPS2.ImportExport.ExportController.SaveImages(...)
22
+
```
23
+
24
+
## Steps to reproduce
25
+
1. Launch NAPS2 from a directory that is later removed or unmounted.
26
+
2. Scan/import pages.
27
+
3. Click **Save Images**.
28
+
29
+
## Expected behavior
30
+
NAPS2 should recover from an invalid CWD and still open the file dialog, falling back to a safe directory (typically user home).
31
+
32
+
## Actual behavior
33
+
An unhandled exception is thrown while creating the dialog handler and the save dialog does not open.
34
+
35
+
## Proposed resolution
36
+
Harden dialog creation in `EtoDialogHelper`:
37
+
38
+
- Before creating dialogs, verify current directory is accessible.
39
+
- If inaccessible (exception or non-existent path), set `Environment.CurrentDirectory` to:
0 commit comments