unity C#设置文件为不可见

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);
            }
        }
    }
}
相关推荐
hez201030 分钟前
Runtime Async - 步入高性能异步时代
c#·.net·.net core·clr
SmalBox9 小时前
【光照】[自发光Emission]以UnityURP为例
unity·渲染
mudtools14 小时前
.NET驾驭Word之力:玩转文本与格式
c#·.net
唐青枫18 小时前
C#.NET 数据库开发提速秘籍:SqlSugar 实战详解
c#·.net
mudtools1 天前
.NET驾驭Word之力:理解Word对象模型核心 (Application, Document, Range)
c#·.net
SmalBox2 天前
【光照】Unity中的[经验模型]
unity·渲染
大飞pkz2 天前
【设计模式】C#反射实现抽象工厂模式
设计模式·c#·抽象工厂模式·c#反射·c#反射实现抽象工厂模式
萘柰奈2 天前
Unity学习----【进阶】TextMeshPro学习(三)--进阶知识点(TMP基础设置,材质球相关,两个辅助工具类)
学习·unity
Yasin Chen2 天前
Unity UI坐标说明
ui·unity
应用市场2 天前
无人机姿态控制系统详解与实现
游戏引擎·cocos2d