Question

        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

Was it helpful?

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());
    }
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top