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. XManager远程Linux 安装Oracle 图形化界面xstart解决方法

    一.安装Oracle_11g_R21.安装所必要的软件包:(CentOS)参见官方文档-rw-r--r--. 1 oracle oinstall 1358454646 Feb  5 22:57 p10 ...

  2. npm 6.0.0 版本npminstall报npm:write after end错误

    这两个多月一直开发小程序,今天准备开发公众号,使用Vue-cli 脚手架搭建项目时候, npm install 就报错误,我就奇葩了!心里一万个曹尼玛....... 因为之前使用安装包的提示升级,自己 ...

  3. python3爬取全民K歌

    Python3爬取全民k歌 环境 python3.5 + requests 1.通过歌曲主页链接爬取 首先打开歌曲主页,打开开发者工具(F12). 选择Network,点击播放,会发现有一个请求返回的 ...

  4. FZU 1980 AbOr's story

    AbOr's story Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original I ...

  5. PNG文件结构分析

    http://blog.163.com/iwait2012@126/blog/static/16947232820124411174877/ PNG文件结构分析 对于一个PNG文件来说,其文件头总是由 ...

  6. Tomcat + Mysql高并发配置优化

    1.Tomcat优化配置 (1)更改Tomcat的catalina.bat 将java变成server模式,增大jvm的内存,在文件开始位置增加 setJAVA_OPTS=-server -Xms10 ...

  7. Android开发学习之事件处理和Button具体解释

    Android的事件处理机制:  1.基于监听器的事件处理 --- 组件绑定特定的事件监听器   --- 重点   2.基于回调的事件处理   --- 主要做法是重写Android组件特定的回调函数, ...

  8. Android使用Fragment,不能得到Fragment内部控件,findViewById()结果是Null--已经解决

    程序很easy.好长时间没有搞定.郁闷.... . .... . . . 在论坛咨询,最终找到答案. 描写叙述: 一个Activity:MainActivity.内部是一个Fragment:Fragm ...

  9. Irrlicht 3D Engine 笔记系列 之 教程6- 2D Graphics

    作者:i_dovelemon 日期:2015 / 7 / 1 来源: CSDN 主题:2D Graphics, Irrlicht 教程翻译 本篇教程将要向大家展示怎样使用Irrlicht引擎绘制2D图 ...

  10. When you are old (当你老了)

    - William Butler Yeats --威廉·巴特勒·叶芝 When you are old and grey and full of sleep: 当你老了,头发花白,睡意沉沉. And ...