I want to get a list of files in a directory except those files being pasted, but my code doesn't work:
static List<string> getListFile(string directory)
{
List<string> listFile = new List<string>();
string[] filePaths = Directory.GetFiles(directory);
foreach (string s in filePaths)
{
FileInfo fileInfo = new FileInfo(s);
long size1 = fileInfo.Length;
Thread.Sleep(2000);
fileInfo = new FileInfo(s);
long size2 = fileInfo.Length;
if (size1 == size2)//This is always true
{
listFile.Add(s);
}
}
return listFile;
}