unity C#设置文件为不可见
csharp
///
///设置文件为隐藏//
///
using UnityEngine;
using System.IO;
public class SetFolderInvisible : MonoBehaviour
{
private void Start()
{
string folderPath = "Qi/Video";
// 将文件夹属性设置为隐藏和系统
SetFolderAttributes(folderPath, FileAttributes.Hidden | FileAttributes.System);
}
private void SetFolderAttributes(string folderPath, FileAttributes attributes)
{
if (Directory.Exists(folderPath))
{
// 获取文件夹下的所有文件和子文件夹
string[] files = Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories);
// 将文件夹的属性设置为隐藏和系统
foreach (var file in files)
{
File.SetAttributes(file, attributes);
}
}
}
}