[Unity][C#][File]File无法新建文件UnauthorizedAccessException,File.Create is denied的解决办法
来源:互联网 发布:中国输电网络先进吗 编辑:程序博客网 时间:2024/06/08 09:16
[Unity][C#][File]File无法新建文件UnauthorizedAccessException,File.Create is denied的解决办法
那就是 保存 一个 模板空 的 blank.txt 文件,然后 复制 移动,写入 新的 文件 到指定的 位置
按照正常 的 是可以正常 创建 文件的。(所有的路径都试过,应该是File.create的问题)
创建文件夹是可以正常使用的。
File.CreateText(path);
if (!File.Exists(path)) { System.IO.Directory.CreateDirectory(path);//创建文件夹 //System.IO.CreateDirectory(path); print("文件夹不存在,创建"+ path); //System.IO.File.Create(path);//创建文件 无法创建 File.CreateText(path); // System.IO.StreamWriter(path); }
但是 UNITY 拒绝 新建Test.txt 文件
UnauthorizedAccessException: Access to the path 'D:/Unity/UnityProjecttestTEST/Time Plan/Assets/StreamingAssets//Test.txt' is denied.
------------------------------------------------
右键新建 文本文档txt
命名为 blank.txt文件
string blankpath = Application.streamingAssetsPath +"/"+ "blank.txt"; string blankpath1 = Application.streamingAssetsPath + "/" + "blank1.txt"; if (!File.Exists(path)) { System.IO.Directory.CreateDirectory(path);//创建文件夹 //System.IO.CreateDirectory(path); print("文件夹不存在,创建"+ path); //System.IO.File.Create(path);//创建文件 无法创建 //File.CreateText(path); // System.IO.StreamWriter(path); File.Copy(blankpath, blankpath1); }
如下图所示, blank1.txt文件,即为 复制的文件。
-------------------------------------------------
参考资料:
1.
【整理】C#文件操作大全(SamWang)
2.
File.Copy 方法
3.
4.
5.
6.
阅读全文
0 0
- [Unity][C#][File]File无法新建文件UnauthorizedAccessException,File.Create is denied的解决办法
- cannot create regular file `XXX': Permission denied
- Create+File
- C++ fstream cannot create file (无法创建文件)
- ArcCatalog连接ArcSDE连接报:unable to create new database connection file,permission is denied
- CodeBlocks,cannot open output file permission denied的解决办法
- CodeBlocks,cannot open output file permission denied的解决办法
- File类 ;File.Create(),File.Delete(), File.Copy(), File.Replace()
- dedetag engine create file false的一个解决办法
- File新建时的参数设置
- C#file文件操作
- zookeeper无法找到myid文件(myid file is missing)
- unity发布失败,文件读取出错的解决方法(The file 'resources.assets' is corrupted)
- visual studio solution file *.sln文件无法双击打开解决办法
- visual studio solution file *.sln文件无法双击打开解决办法
- visual studio solution file *.sln文件无法双击打开解决办法 .
- DDMS中File Explorer无法查看data/data文件解决办法
- DDMS中File Explorer无法查看data/data文件解决办法
- (笔记)为何boost中boost::shared_ptr 循环引用会导致引用计数机制失效
- Hadoop实战(9)_Hive进阶及UDF开发
- value.toFixed is not a function
- Chrome浏览器快捷键
- 变量加载顺序
- [Unity][C#][File]File无法新建文件UnauthorizedAccessException,File.Create is denied的解决办法
- Android进阶(二)--序列化Serializable和Parcelabel使用与区别
- spring-cloud【eureka】
- js 读取excel
- 解读:大数据在电信行业的五大应用
- [leetcode]#27. Remove Element
- MySQL tinyint/smallint/int/bigint
- spring boot 遇到的坑
- async.js