Search code examples
c#filefileinfodirectoryinfo

Not reading the content of files in wpf


        var dir = new DirectoryInfo(Path);
        foreach (FileInfo flInfo in dir.GetFiles())
        {
            String name = flInfo.Name;
            long size = flInfo.Length;
            DateTime creationTime = flInfo.CreationTime;
            const int counter = 0;
            int count = counter + 1;
        }

I am getting the path but not not reading the content and file info


Solution

    1. I do not understand, why you need counter variable
    2. You do not try read the content. If you want read the file, use stream to read it:

      using (StreamReader reader = flInfo.OpenText())
      {
      Console.WriteLine(reader.ReadToEnd());
      }