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

No error or dialog if filename has an incorrect character #926

Closed
tobiasht opened this issue Dec 17, 2021 · 6 comments · Fixed by #940
Closed

No error or dialog if filename has an incorrect character #926

tobiasht opened this issue Dec 17, 2021 · 6 comments · Fixed by #940
Assignees
Labels
desktop The issue applies to Windows, Linux or MacOS implementations. new issue An issue that hasn't yet been seen from the maintainer

Comments

@tobiasht
Copy link

I was trying to run the following code on Windows.

final String? outputFile = await FilePicker.platform.saveFile(
    dialogTitle: 'Save as:',
    fileName: "Exported: $deviceName.json"
    allowedExtensions: ["json"],
    type: FileType.custom,
  );

The dialog did not open and it only returned null. I figured out that it was because i was using ":" in the filename. This might be an invalid character and might be by design. Either way, I believe it should throw an error, to easily figure out the problem.

@tobiasht tobiasht added the new issue An issue that hasn't yet been seen from the maintainer label Dec 17, 2021
@philenius
Copy link
Collaborator

philenius commented Dec 18, 2021

@tobiasht I'm sorry, but the use of a colon : in a file name is generally not allowed on Windows, as Microsoft officially states here:
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

[...] except for the following:

  • The following reserved characters:

    • < (less than)
    • > (greater than)
    • : (colon)
    • " (double quote)
    • / (forward slash)
    • \ (backslash)
    • | (vertical bar or pipe)
    • ? (question mark)
    • * (asterisk)
  • Integer value zero, sometimes referred to as the ASCII NUL character.

  • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.

  • Any other character that the target file system does not allow.

Windows Explorer doesn't even allow you to type a colon in a file name:

grafik

@philenius philenius added the desktop The issue applies to Windows, Linux or MacOS implementations. label Dec 18, 2021
@tobiasht
Copy link
Author

Yeah i understand that, but it would be more helpful to raise an invalid character exception. If that is possible. It will save people a lot of troubleshooting in the future.

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Dec 26, 2021
@philenius philenius removed the stale label Dec 27, 2021
@github-actions
Copy link

github-actions bot commented Jan 4, 2022

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Jan 4, 2022
@miguelpruivo
Copy link
Owner

@philenius do you plan to do anything regarding this?

@philenius
Copy link
Collaborator

@miguelpruivo please excuse my late reply. Merge request #940 adds the requested exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Development

Successfully merging a pull request may close this issue.

3 participants