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

How to edit hidden files on windows? #52401

Closed
Lenny4 opened this issue May 15, 2023 · 1 comment
Closed

How to edit hidden files on windows? #52401

Lenny4 opened this issue May 15, 2023 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io os-windows

Comments

@Lenny4
Copy link

Lenny4 commented May 15, 2023

Windows 10

Here is my code:

import 'dart:io';

void main(List<String> args) {
  File('C:\\Users\\alexa\\Documents\\test\\my-file.txt').writeAsString("some-text"); // got error if hidden, no error if not hidden
}

When I run this code on windows and the file is NOT hidden everything works nice.

But when I hide the file I got error:

Unhandled Exception: PathAccessException: Cannot open file, path = 'C:\Users\alexa\Documents\test\my-file.txt' (OS Error: Accès refusé.

, errno = 5)

Notice that when I run this code on an hidden file I get the data of the file:

import 'dart:io';

void main(List<String> args) {
  File('C:\\Users\\alexa\\Documents\\test\\my-file.txt').readAsStringSync(); // everything works fine here, even on hidden file
}

In both case the file was not in read only mode. He had only the +H attribute.

+R - Use the +R option to make a file read-only. Read-only files may be
read but they can`t be changed or deleted.

-R - Use the -R option to change the file protection attribute back to normal (so it can be read, changed, or deleted).

+A - Use the +A option to set the ARCHIVE attribute of a file. When the +A option is used, this flags the file as available for archiving
when using the BACKUP or XCOPY commands.

-A - Use the -A option to turn off the ARCHIVE attribute.

+H - With DOS Versions 4 through 6, use the +H option to set the HIDDEN attribute of a file so that it will not appear in a directory
listing.

-H - Use the -H option to turn off the HIDDEN attribute.

+S - With DOS Versions after Version 4, use the +S option to set the SYSTEM attribute of a file. When the +S option is used, this flags the
file as a command file used only by DOS. The file will not appear in a
directory listing. This attribute is generally reserved for
programmers.

-S - Use the -S option to turn off the SYSTEM attribute.

/S - Use the /S switch to set attributes on subdirectories found
within the specified path.

RwQDR

Why can't I edit an hidden file with dart ?

The solution I found is to create a hidden directory and put my file in this directory. So the file is not hidden but the directory is. This way I can edit the file.

@Lenny4 Lenny4 changed the title Create an issue How to edit hidden files on windows? May 15, 2023
@lrhn
Copy link
Member

lrhn commented May 15, 2023

Seems to be a recurring issue on Windows, e.g. golang/go#25923

@lrhn lrhn added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io os-windows labels May 15, 2023
@Lenny4 Lenny4 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io os-windows
Projects
None yet
Development

No branches or pull requests

2 participants