Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 隐藏/取消隐藏文件不太好用_C#_Forms_Winforms_Visual Studio_File - Fatal编程技术网

C# 隐藏/取消隐藏文件不太好用

C# 隐藏/取消隐藏文件不太好用,c#,forms,winforms,visual-studio,file,C#,Forms,Winforms,Visual Studio,File,我用它来隐藏文件: File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); 但是当我想取消隐藏该文件时,该文件刚刚被删除,但在代码中我没有得到任何错误,因此该文件仍然存在 File.SetAttributes(path, File.GetAttributes(path) | ~FileAttributes.Hidden); 你可以用它做一个简单的检查 bool b = File.Exists(St

我用它来隐藏文件:

File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
但是当我想取消隐藏该文件时,该文件刚刚被删除,但在代码中我没有得到任何错误,因此该文件仍然存在

File.SetAttributes(path, File.GetAttributes(path) | ~FileAttributes.Hidden);

你可以用它做一个简单的检查

bool b = File.Exists(String path)

你可以用它做一个简单的检查

bool b = File.Exists(String path)
:

:


好。工作不太好。要禁用单个位,可能需要使用的是重复的
&
,而不是
|
。在链接问题中查找示例。如果有什么不适合你,请用必要的细节更新你的问题。工作不太好。要禁用单个位,可能需要使用的是重复的
&
,而不是
|
。在链接问题中查找示例。如果有什么不适合你,请用必要的细节更新你的问题。以及我如何取消隐藏文件?也许这就是你要找的,我如何取消隐藏文件?也许这就是你要找的