convert a FileInfo array into a String array C#

前端 未结 4 1172
春和景丽
春和景丽 2021-01-05 05:17

I create a FileInfo array like this

 try
            {
                DirectoryInfo Dir = new DirectoryInfo(DirPath);
                FileInfo[] FileList =          


        
4条回答
  •  余生分开走
    2021-01-05 05:53

    the linq is a great soluction, but for the persons who don't want to use linq, i made this function:

        static string BlastWriteFile(FileInfo file)
        {
            string blasfile = " ";
            using (StreamReader sr = file.OpenText())
            {
                string s = " ";
                while ((s = sr.ReadLine()) != null)
                {
                    blasfile = blasfile + s + "\n";
                    Console.WriteLine();
                }
            }
            return blasfile;
        }
    

提交回复
热议问题