我正在尝试编写一个程序,它将列出目录并显示文件?子目录和文件扩展名。但是在我的代码的某个地方,我有一个问题。我成功加载文件和目录,但是当我尝试写入文件类型时,我不能这样做
class Program
{
static void Main(string[] args)
{
int i;
string dir, mask;
Console.WriteLine("Enter file mask:");
mask = Console.ReadLine();
Console.WriteLine("Enter directory:");
dir = Console.ReadLine();
if (!Directory.Exists(dir))
{
Console.WriteLine("No such directory");
Console.Read();
}
else
{
string[] files = Directory.GetFiles(dir, "*" + mask + "*", SearchOption.AllDirectories);
string[] folders = Directory.GetDirectories(dir, "*", SearchOption.AllDirectories)
string[] files_types = new string[files.Length];
int file_i, type_i;
for (file_i = 0; file_i == files.Length;file_i++)
{
string curr_file = files[file_i];
string f_type = "";
{
for (type_i = 0; type_i == curr_file.Length; type_i++)
{
if (curr_file[type_i].ToString() == ".")
{
int dot_place;
for (dot_place = type_i; dot_place == curr_file.Length; dot_place++)
{
f_type += curr_file[dot_place].ToString();
}
}
}
files_types[file_i] = f_type;
}
}
for (i=0;i==files.Length;i++)
{
Console.WriteLine("========================FILES=======================");
Console.WriteLine(files[i]);
}
for (i = 0; i == folders.Length;i++)
{
Console.WriteLine("========================FOLDERS=======================");
Console.WriteLine(files[i]);
}
for (i = 0; i == files_types.Length; i++)
{
Console.WriteLine("========================TYPES=======================");
Console.WriteLine(files[i]);
}
Console.Read();
}
}
}
我不明白在哪里。