File Storage Management in Unity3d

Source: Internet
Author: User

use Path object to determine path integrity and correctness
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} have 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 have 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\c         Onsoleapplication2\bin\debug\temp.         * D:\Documents and Settings\cliffc\local settings\temp\8\ are the location for temporary files.         * D:\Documents and Settings\cliffc\local settings\temp\8\tmp3d.tmp is a file available for use. */    }}
Create a file with FileInfo
Using system;using system.io;class Test {public static void Main () {//Gets the cache path through the path object string path =        Path.gettempfilename ();        FileInfo fi1 = new FileInfo (path); Creates a file and writes the data using a "file stream write Object" (StreamWriter SW = fi1). CreateText ()) {SW.            WriteLine ("Hello"); Sw.            WriteLine ("and"); Sw.        WriteLine ("Welcome"); }//Opens the file and reads the data using (StreamReader sr = fi1) by returning the "file stream read Object".            OpenText ()) {string s = ""; while (s = Sr.            ReadLine ()) = null) {Console.WriteLine (s);            }} try {string path2 = Path.gettempfilename ();            FileInfo fi2 = new FileInfo (path2); Delete File Fi2.            Delete (); Copy the F1 file to the F2 file FI1.            CopyTo (path2);            Console.WriteLine ("{0} is copied to {1}.", Path, path2); Delete File Fi2.            Delete (); Console.WriteLine ("{0} wasSuccessfully deleted. ", path2);        } catch (Exception e) {Console.WriteLine ("The process failed: {0}", e.tostring ()); }    }}

  

File Storage Management in Unity3d

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.