我想隐藏在C#中的文件。我知道文件的路径,并可以创建FileInfo对象。
I want to hide a file in c#. I know the file path and can create a FileInfo object.
如何隐藏呢?
接受的答案:
File.SetAttributes(path, FileAttributes.Hidden);
将导致它可能会丢失某些其他属性,所以你应该:
will result in certain other attributes it may have being lost, so you should:
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);