UNITY3D中的文件存储管理
使用Path对象判断路径的完整性和正确性
using System;
using System.IO; class Test
{ public static void Main()
{
string path1 = @"c:\temp\MyTest.txt";
string path2 = @"c:\temp\MyTest";
string path3 = @"temp"; if (Path.HasExtension(path1))
{
Console.WriteLine("{0} has an extension.", path1);
} if (!Path.HasExtension(path2))
{
Console.WriteLine("{0} has no extension.", path2);
} if (!Path.IsPathRooted(path3))
{
Console.WriteLine("The string {0} contains no root information.", path3);
} Console.WriteLine("The full path of {0} is {1}.", path3, Path.GetFullPath(path3));
Console.WriteLine("{0} is the location for temporary files.", Path.GetTempPath());
Console.WriteLine("{0} is a file available for use.", Path.GetTempFileName()); /* This code produces output similar to the following:
* c:\temp\MyTest.txt has an extension.
* c:\temp\MyTest has no extension.
* The string temp contains no root information.
* The full path of temp is D:\Documents and Settings\cliffc\My Documents\Visual Studio 2005\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\temp.
* D:\Documents and Settings\cliffc\Local Settings\Temp\8\ is the location for temporary files.
* D:\Documents and Settings\cliffc\Local Settings\Temp\8\tmp3D.tmp is a file available for use.
*/
}
}
使用FileInfo创建文件
using System;
using System.IO; class Test
{ public static void Main()
{
//通过Path对象获取缓存路径
string path = Path.GetTempFileName();
FileInfo fi1 = new FileInfo(path); //创建文件,并且通过返回的"文件流写入对象"写入数据
using (StreamWriter sw = fi1.CreateText())
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
} //打开文件,并且通过返回的"文件流读取对象"读取数据
using (StreamReader sr = fi1.OpenText())
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
} try
{
string path2 = Path.GetTempFileName();
FileInfo fi2 = new FileInfo(path2); //删除文件
fi2.Delete(); //将f1文件拷贝到f2文件
fi1.CopyTo(path2);
Console.WriteLine("{0} was copied to {1}.", path, path2); //删除文件
fi2.Delete();
Console.WriteLine("{0} was successfully deleted.", path2); }
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}
UNITY3D中的文件存储管理的更多相关文章
- Unity3d 在不同设备中的文件读写 的路径
Application.dataPath : 数据路径 Unity Editor: <path tp project folder>/Assets Unity 编辑器:<工程文件 ...
- X-UniTMX:导入大型Tiled地图文件(*.tmx)到Unity3d中比较好的插件
因工作原因,需要导入格子数为1200x1200的Tiled地图文件(*.tmx)到Unity3d中显示出来.尝试过一些其它插件,后面发现X-UniTMX是比较好用的. X-UniTMXhttp://f ...
- Unity3d发布apk文件并在Android虚拟机中运行的操作流程
总的流程分为以下6个步骤: 1.安装java_jdk 2.配置java环境变量 3.更新android的sdk 4.从Unity3d中发布出apk文件 5.创建android虚拟机并运行 6.将apk ...
- 图文详解Unity3D中Material的Tiling和Offset是怎么回事
图文详解Unity3D中Material的Tiling和Offset是怎么回事 Tiling和Offset概述 Tiling表示UV坐标的缩放倍数,Offset表示UV坐标的起始位置. 这样说当然是隔 ...
- Unity3D中C#和js方法相互调用
通过查找资料,Unity3D中C#和js要相互调用彼此的方法,js文件必须放在"Standard Assets". "Pro Standard Assets" ...
- [Unity3D][Vuforia][IOS]vuforia在unity3d中添加自己的动态模型,识别自己的图片,添加GUI,播放视频
使用环境 unity3D 5 pro vuforia 4 ios 8.1(6.1) xcode 6.1(6.2) 1.新建unity3d工程,添加vuforia 4.0的工程包 Hierarchy中 ...
- 浅析游戏引擎的资源管理机制——扒一扒Unity3D中隐藏在背后的资源管理
游戏中通常有大量资源,如网格.材质.纹理.动画.着色器程序和音乐等,游戏引擎作为做游戏的工具,自然要提供良好的资源管理,让游戏开发者用最简单的方式使用资源.游戏引擎的资源管理包括两大部分:离线资源管理 ...
- 在unity3d中连接sql server
虽然在Unity3D中能够通过PlayerPrefs类来保存和读取数据,但是一旦数据量增大,仅仅通过代码的方式存取数据,这样的工作量是非常大的.那么如何通过使用Sql Server数据库来存取数据呢? ...
- 关于Unity3D中的版本管理 .
关于Unity3D中的版本管理 使用Unity3D也有一段时间了,由于团队一直使用SVN进行版本管理,现总结一下: (1) Unity3D的二进制资源必须加锁进行版本控制,因为它没办法merge: ( ...
随机推荐
- jsp提交表单问题
以form形式提交的话 String usernameInForm = hreq.getParameter("username");String passwordInForm = ...
- Android OpenGL ES(五)GLSurfaceView .
Android OpenGL ES 相关的包主要定义在 javax.microedition.khronos.opengles GL 绘图指令 javax.microedition.khrono ...
- 为什么Hbase能实现快速的查询
你的快速是指什么? 是根据亿级的记录中快速查询,还是说以实时的方式查询数据. A:如果快速查询(从磁盘读数据),hbase是根据rowkey查询的,只要能快速的定位rowkey, 就能实现快速的查询 ...
- hosts文件不显示
1.按住windows键(就是小旗子小窗口键)+R,打开运行:2.在输入框中输入 cmd并回车:3.紧接着在dos窗口中输入"CD \WINDOWS\SYSTEM32\DRIVERS\ETC ...
- 动态规划1-----------poj1080
#include<cstdio> #include<cstdlib> #include<iostream> #include<algorithm> us ...
- js的阻塞特性
JS具有阻塞特性,当浏览器在执行js代码时,不能同时做其它事情,即<script>每次出现都会让页面等待脚本的解析和执行(不论JS是内嵌的还是外链的),JS代码执行完成后,才继续渲染页面. ...
- Elkstack2.0部署
部署步骤如下: 1.1 资源拷贝 1 jdk1.8 2 kafka 3 kafka-manager 1.2 jvm 配置 vim /etc/profile.d/java.sh JAVA_HOME=/u ...
- ssh-copy-id
建立无密码登录是经现root成功普通用户失败, chmod 0600 authorized_keys setenforce 0 ssh-copy-id server2 ssh-add ~/.ss ...
- svg都快忘了,复习一下
http://www.360doc.com/content/07/0906/21/39836_724430.shtml
- Sonya and Problem Wihtout a Legend
Sonya and Problem Wihtout a Legend Sonya was unable to think of a story for this problem, so here co ...