class FileSysInfo
{
static void Main()
{
// You can also use System.Environment.GetLogicalDrives to
// obtain names of all logical drives on the computer.
System.IO.DriveInfo di = new System.IO.DriveInfo(@"C:\");
Console.WriteLine(di.TotalFreeSpace);
Console.WriteLine(di.VolumeLabel); // Get the root directory and print out some information about it.
System.IO.DirectoryInfo dirInfo = di.RootDirectory;
Console.WriteLine(dirInfo.Attributes.ToString()); // Get the files in the directory and print out some information about them.
System.IO.FileInfo[] fileNames = dirInfo.GetFiles("*.*"); foreach (System.IO.FileInfo fi in fileNames)
{
Console.WriteLine("{0}: {1}: {2}", fi.Name, fi.LastAccessTime, fi.Length);
} // Get the subdirectories directly that is under the root.
// See "How to: Iterate Through a Directory Tree" for an example of how to
// iterate through an entire tree.
System.IO.DirectoryInfo[] dirInfos = dirInfo.GetDirectories("*.*"); foreach (System.IO.DirectoryInfo d in dirInfos)
{
Console.WriteLine(d.Name);
} // The Directory and File classes provide several static methods
// for accessing files and directories. // Get the current application directory.
string currentDirName = System.IO.Directory.GetCurrentDirectory();
Console.WriteLine(currentDirName); // Get an array of file names as strings rather than FileInfo objects.
// Use this method when storage space is an issue, and when you might
// hold on to the file name reference for a while before you try to access
// the file.
string[] files = System.IO.Directory.GetFiles(currentDirName, "*.txt"); foreach (string s in files)
{
// Create the FileInfo object only when needed to ensure
// the information is as current as possible.
System.IO.FileInfo fi = null;
try
{
fi = new System.IO.FileInfo(s);
}
catch (System.IO.FileNotFoundException e)
{
// To inform the user and continue is
// sufficient for this demonstration.
// Your application may require different behavior.
Console.WriteLine(e.Message);
continue;
}
Console.WriteLine("{0} : {1}",fi.Name, fi.Directory);
} // Change the directory. In this case, first check to see
// whether it already exists, and create it if it does not.
// If this is not appropriate for your application, you can
// handle the System.IO.IOException that will be raised if the
// directory cannot be found.
if (!System.IO.Directory.Exists(@"C:\Users\Public\TestFolder\"))
{
System.IO.Directory.CreateDirectory(@"C:\Users\Public\TestFolder\");
} System.IO.Directory.SetCurrentDirectory(@"C:\Users\Public\TestFolder\"); currentDirName = System.IO.Directory.GetCurrentDirectory();
Console.WriteLine(currentDirName); // Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}

unity C# 获取有关文件、文件夹和驱动器的信息的更多相关文章

  1. 获取WINDOWS特殊文件夹

    const// registry entries for special paths are kept in :  REGSTR_PATH_SPECIAL_FOLDERS   = REGSTR_PAT ...

  2. JAVA之旅(二十八)——File概述,创建,删除,判断文件存在,创建文件夹,判断是否为文件/文件夹,获取信息,文件列表,文件过滤

    JAVA之旅(二十八)--File概述,创建,删除,判断文件存在,创建文件夹,判断是否为文件/文件夹,获取信息,文件列表,文件过滤 我们可以继续了,今天说下File 一.File概述 文件的操作是非常 ...

  3. java 弹出选择目录框(选择文件夹),获取选择的文件夹路径

    java 弹出选择目录框(选择文件夹),获取选择的文件夹路径 java 弹出选择目录框(选择文件夹),获取选择的文件夹路径:int result = 0;File file = null;String ...

  4. python 如何获取当前文件/文件夹

    python 如何获取当前文件/文件夹? 1.获取当前文件的实际路劲: os.path.realpath(__file__)          ==> D:\python_test\test_p ...

  5. Unity中一键创建常用文件夹

    Unity中一键创建常用文件夹 说明 项目测试版本Unity5.3. 这个一个小工具:功能非常简单,就是一键给新建工程添加所有文件夹.到此结束. 但是具体咋操作呢? 与把大象装进冰箱一样,三步,下载代 ...

  6. Unity中所有特殊的文件夹

    1. 隐藏文件夹以.开头的文件夹会被Unity忽略.在这种文件夹中的资源不会被导入,脚本不会被编译.也不会出现在Project视图中.2. Standard Assets在这个文件夹中的脚本最先被编译 ...

  7. Java根路径设置(在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了)

    在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了

  8. File类 递归 获取目录下所有文件文件夹

    package com.xiwi; import java.io.*; import java.util.*; class file{ public static void main(String a ...

  9. 用C#操作文件/文件夹(删除,复制,移动)

    操作某一个文件/文件夹,需要一个文件的完整路径 一.使用File的静态方法进行文件操作 //使用file的静态方法进行复制 File.Copy(path, destpath); //使用File的静态 ...

随机推荐

  1. 服务器搭建域控与SQL Server的AlwaysOn环境过程(一) 搭建域控服务器

    0 准备阶段 1. Windows Server 服务器 3台(其中域控服务器配置可降低一个水准,目前博主试用的是:域控服务器--2核4G 数据库服务器(节点)--4核8G ) 2. SQL Serv ...

  2. js得到区域长宽

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  3. [agc004c]and grid

    别问我为什么咕了两天 题意: 给出一个$H\times W$的网格图A,仅由'.'和'#'构成,边界上没有'#'且至少有一个'#'.构造两个网格图B和C,大小均为$H\times W$,要求A中为'# ...

  4. LightOJ-1220 Mysterious Bacteria 唯一分解定理 带条件的最大公因数

    题目链接:https://cn.vjudge.net/problem/LightOJ-1220 题意 给x=y^p,问p最大多少 注意x可能负数 思路 唯一分解定理,求各素因数指数的GCD 注意负数的 ...

  5. bootstrap 因跳页黑色背景无法关闭

    只需要在跳页之前加上如下代码: $(".modal-backdrop").remove();

  6. 《剑指Offer》——试题1:赋值运算符函数

    题目:如下类型为CMyString的声明,请为该类型添加赋值运算符函数.   class CMyString { public: CMyString(char* pData = NULL); CMyS ...

  7. oracle数据库回滚

    线下测试数据误操作,回滚攻略--把数据捞出来,这个时间自己设置--表名一定要是:xx_tbd日期 CREATE TABLE user_tbd0718ASselect * from user as of ...

  8. Java Class文件结构

    此文件格式为JAVA7的格式,可能与JAVA6 CLASS不一致. 每一个Class都对应着唯一的一个类或借口的定义信息.这里,我们称为"Class文件格式"只是通俗的将任意一个符 ...

  9. centos6.5安装配置nginx+php+mysql+httpsqs+ttserver+redis

    一.准备 1.nginx, http://nginx.org/download/nginx-1.5.12.tar.gz 2.pcre, ftp://ftp.csx.cam.ac.uk/pub/soft ...

  10. Qt之图形(组合)

    简述 使用QPainter绘制图形或者图像时,在重叠区域使用组合模式(Composition_mode).在绘图设备上通过组合模式使用QImage时,必须使用Format_ARGB32_Premult ...