Unity 本地文件夹 目录查找,判断有否 没有创建 有删除。
来源:互联网 发布:java基础代码 编辑:程序博客网 时间:2024/05/17 07:09
using System.Collections;using System.Collections.Generic;using System.IO;using UnityEngine;public class shanchu : MonoBehaviour { string path= @"D:\\a2"; void Start () { } void Update () { if (Input.GetKeyDown(KeyCode.Q)) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); print("文件夹不存在,创建"); } else { DirectoryInfo file1 = new DirectoryInfo(path); deleteDirs(file1); file1 = null; print("文件夹存在,删除"); } } } void deleteDirs(DirectoryInfo dirs) { if (dirs == null || (!dirs.Exists)) { return; } DirectoryInfo[] subDir = dirs.GetDirectories(); if (subDir != null) { for (int i = 0; i < subDir.Length; i++) { if (subDir[i] != null) { deleteDirs(subDir[i]); } } subDir = null; } FileInfo[] files = dirs.GetFiles(); if (files != null) { for (int i = 0; i < files.Length; i++) { if (files[i] != null) { Debug.Log("删除文件:" + files[i].FullName + "__over"); files[i].Delete(); files[i] = null; } } files = null; } Debug.Log("删除文件夹:" + dirs.FullName + "__over"); dirs.Delete(); }}
阅读全文
1 0
- Unity 本地文件夹 目录查找,判断有否 没有创建 有删除。
- iOS 访问本地沙盒路径,创建文件夹,判断是否已创建再创建文件夹,写数据到创建目录
- 文件夹创建删除和判断
- 判断文件夹下有没有文件
- 判断文件夹是否有了,没有则创建文件夹
- 判断文件夹是否有了,没有则创建文件夹
- 乱码文件夹 rm 无法删除...": 没有那个文件或目录
- 使用java代码在本地创建文件夹(多层目录),在本地磁盘创建文件目录
- Winodws删除目录失败--查找文件句柄没有关闭
- ubuntu没有权限(不能)创建文件夹(目录)
- ubuntu没有权限(不能)创建文件夹(目录)
- ubuntu没有权限(不能)创建文件夹(目录)
- 判断一个链表有否有环。有的话求出链表长度、环长度和连接点。
- .net删除本地文件夹
- unity动态创建文件夹
- C#对文件夹的判断、创建、移动、删除
- C#对文件夹的判断、创建、移动、删除
- C#对文件夹的判断、创建、移动、删除
- jsp中page的各个属性介绍
- android改进布局性能
- Android中Vitamio全屏播放
- 系统间通信—信息格式
- 秒针机器学习面试
- Unity 本地文件夹 目录查找,判断有否 没有创建 有删除。
- 开屏广告实现
- 8.30 PPT word excel小技巧
- zookeeper注册服务,开机自启动
- web+git
- java中流对文件的操作
- Android 7.0 bluetooth introduction
- leetcode01 Two Sum 寻找列表中和为定值的元素位置
- Apache Kafka监控之Kafka Web Console