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

The current directory was changed after pick a file #1254

Closed
MahmoudKEA opened this issue Apr 4, 2023 · 6 comments · Fixed by #1256
Closed

The current directory was changed after pick a file #1254

MahmoudKEA opened this issue Apr 4, 2023 · 6 comments · Fixed by #1256
Labels
bug Something isn't working desktop The issue applies to Windows, Linux or MacOS implementations. new issue An issue that hasn't yet been seen from the maintainer

Comments

@MahmoudKEA
Copy link

MahmoudKEA commented Apr 4, 2023

I noticed after i picked a file, the current directory has changed!

print(Directory.current.path); // "D:\Workspace\"

// I picked a file from desktop
FilePicker.platform.pickFiles(lockParentWindow: true).then((result) {
    print(Directory.current.path);  // "C:\Users\darkn\Desktop\"
});

My simple solution to restore my workspace again as below

final Directory currentDir = Directory.current;

FilePicker.platform.pickFiles(lockParentWindow: true).then((result) {
    Directory.current = currentDir;
});
@MahmoudKEA MahmoudKEA added the new issue An issue that hasn't yet been seen from the maintainer label Apr 4, 2023
@philenius
Copy link
Collaborator

philenius commented Apr 4, 2023

I would appreciate if you could search for similar issues before creating a new one. Thank you.

Related to #804 and already implemented in PR #1022 but was closed. I will look into it.

@philenius philenius added the desktop The issue applies to Windows, Linux or MacOS implementations. label Apr 4, 2023
philenius added a commit that referenced this issue Apr 5, 2023
Previously, on Windows, the current directory changed after picking
a file. Turns out, there's an extra option to restore the current
directory after picking a file or directory.
@MahmoudKEA
Copy link
Author

@philenius Great work, Thank you

@philenius philenius reopened this Apr 6, 2023
@philenius
Copy link
Collaborator

I'm still working on it and will most probably create a pull request tonight.

@philenius
Copy link
Collaborator

@MahmoudKhalid please check-out the branch of my pull request #1256 and run the example app to check whether your issue has been resolved! Can you confirm that it is now working as it should?

@MahmoudKEA
Copy link
Author

@philenius Yes, I just tried it on windows 11
It works fine, Thank you

@philenius
Copy link
Collaborator

Thank you so much for your quick response. My pull request is now waiting for Miguel's approval. Might take a few days.

miguelpruivo added a commit that referenced this issue Apr 12, 2023
…tory-changes-after-picking-files

Fixes #1254 so that the current directory is not changed after the used picked files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working desktop The issue applies to Windows, Linux or MacOS implementations. new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
2 participants