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
Setting hidden attributes on Directory in Linux / Mac does not work.
If I set the hidden attribute to a DirectoryInfo class the directory does not become hidden.
Sample Code shows the problem.
`
namespace test_hidden_directory
{
class Program
{
static void Main(string[] args)
{
string path = @"/Users/bobm/hidden-test-directory";
if ( !Directory.Exists( path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
di.Attributes |= FileAttributes.Hidden;
}
else
{
DirectoryInfo dir = new DirectoryInfo(path);
dir.Attributes &= ~FileAttributes.Hidden;
}
}
}
`
When I set the di.attributes to hidden the directory does not disappear, in addition when I rerun the code the attributes of the file are hidden so the setting of the attributes is working correctly however the directory does not get hidden.
The documentation does indicate that the Hidden attribute does work for MAC and Linux.
I think it's a documentation bug. It should be clarifying that Hidden is a file attribute that's returned on Linux, but can't be set explicitly. That same page says:
On Unix systems, the value returned by File.GetAttributes includes Hidden for a file whose name begins with a period ("."). On macOS, you can get or set the hidden flag.
(I am not sure the second sentence is correct, tbh, but I dont use macOS.)
"Hiding" files works by renaming the files on Linux. I am not sure how the Hidden attribute could be set without modifying the file name on Linux.
Shouldn't the runtime throw an notSupportedException if your setting the HIDDEN bit and the underlying OS does not support the operation, unless setting the hidden bit would actually rename the filename to .filename.
This is a known issue which we have open in dotnet/runtime: dotnet/runtime#37301
We had a fix for it but had to back it out because it introduced a perf regression. We are working on addressing it again.
Closing this issue in favor of that one.
Setting hidden attributes on Directory in Linux / Mac does not work.
If I set the hidden attribute to a DirectoryInfo class the directory does not become hidden.
Sample Code shows the problem.
`
namespace test_hidden_directory
{
`
When I set the di.attributes to hidden the directory does not disappear, in addition when I rerun the code the attributes of the file are hidden so the setting of the attributes is working correctly however the directory does not get hidden.
The documentation does indicate that the Hidden attribute does work for MAC and Linux.
https://docs.microsoft.com/en-us/dotnet/api/system.io.fileattributes?view=netcore-3.1
dotnet --info output.
pi@raspberrypi-4:~/test-hidden-directory$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961
Runtime Environment:
OS Name: raspbian
OS Version: 10
OS Platform: Linux
RID: linux-arm
Base Path: /usr/share/dotnet/sdk/3.1.101/
Host (useful for support):
Version: 3.1.7
Commit: fcfdef8d6b
.NET Core SDKs installed:
3.1.101 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The text was updated successfully, but these errors were encountered: