using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections;
namespace ConsoleApplication2
{
class Program
{
static void ListDir(FileSystemInfo dir_info)
{
DirectoryInfo dir = dir_info as DirectoryInfo;
if (dir != null)
{
FileSystemInfo[] files = dir.GetFileSystemInfos();
for (int i = 0; i < files.Length; i++)
{
FileInfo file = files[i] as FileInfo;
if (file != null)
{
Console.WriteLine(file.Directory.Name + " = " + file.Name + ‘ ‘ + file.Length);
}
else
{
//ListDir(files[i]);
}
}
}
}
static void Main(string[] args)
{
string str = "20070529";
IFormatProvider format = new System.Globalization.CultureInfo("zh-CN");
string TarStr = "yyyyMMdd";
try
{
DateTime MyDate = DateTime.ParseExact(str, TarStr, format);
Console.WriteLine("+++++ " + MyDate);
ArrayList strs = new ArrayList();
strs.Add(str);
strs.Add("++++++++++++++");
strs.Add(str);
strs.Add("______________");
strs.Add(str);
strs.Add("---------------");
strs.Add(str);
string[] strss = {"a", "b", "c", "d", "e", "f"};
string[] arrString = (string[])strs.ToArray(typeof(string));
File.WriteAllLines(@"C:\ddddddd6.txt", arrString);
File.WriteAllText(@"C:\ddddddd2.txt", "===================");
FileInfo myFile = new FileInfo(@"C:\ddddddd3.txt");
StreamWriter sw5 = myFile.CreateText();
sw5.WriteLine("aaaaaa");
sw5.WriteLine("aaaaaa");
sw5.WriteLine("aaaaaa");
sw5.WriteLine("aaaaaa");
sw5.WriteLine("aaaaaa");
sw5.Close();
FileStream fs1 = new FileStream(@"C:\ddddddd4.txt", FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine("aaaaaa");
sw.WriteLine("aaaaaa");
sw.WriteLine("aaaaaa");
sw.WriteLine("aaaaaa");
sw.WriteLine("aaaaaa");
sw.Close();
fs1.Close();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
while (true)
{
Console.Write("请输入要查询的目录: ");
string dirname = Console.ReadLine();
if (dirname == " ")
{
break;
}
DirectoryInfo dir_info = new DirectoryInfo(dirname);
ListDir(dir_info);
}
}
}
}