unity C#设置文件为不可见
///
///设置文件为隐藏//
///
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);}}}
}