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.
Why can't I edit an hidden file with dart ?