Currently I am getting the size of a file by using:
FileInfo fileSize = new FileInfo(@"C:\file.txt");
long size = fileSize.Length;
Rather than do this for every file I want, I thought you must be able to use an array and iterate through them so I used this:
FileInfo[] fileSizes = new FileInfo[2];
fileSizes[0] = @"C:\file.txt";
fileSizes[1] = @"C:\file.txt";
Now I keep getting the error “Cannot implicitly convert type ‘string’ to ‘System.IO.FileInfo'”. I tried using .ToString() but no dice, any help is very appreciated, thanks!
You shouldn’t store multiple files in a
FileInfoarray. To fix your error, you need to do this:However, you should store them like this (below) and iterate through the list and load one
FileInfoat a time: