很久没有写博客了,今天和大家分享一下关于在unity中怎么去读取文件直接源码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class ReadPath : MonoBehaviour {
private string Path;//定义路径
DirectoryInfo info;//文件路径
// Use this for initialization
void Start () {
Path = "D://baozaodedianxiaoer/";//创建文件路径
if (!Directory.Exists(Path))//判断路径是否存在
{
Directory.CreateDirectory(Path);//创建文件
}
else
{
string[] VideoName = Directory.GetFileSystemEntries(Path);//获取这个路径下的所有文件
info = new DirectoryInfo(VideoName[0]);
Debug.Log(info);//文件夹下的第一个文件的路径
string str = info.Name.Split('.')[0];
Debug.Log(str);//名字
}
}
}