Imagine a winform application that copies updated assemblies from source folder A to destination folder B. I use the simple methods DirectoryInfo.GetFiles to populate the list by comparing the version of the assembly in folder A and B; if some builds are newer, I start my update method. In this method, before copying, I try if all the files in folder B are not used:
var B = new DirectoryInfo("myBfolder");
foreach (var file in aFolder.GetFiles())
{
try
{
File.Open(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (Exception ex)
{
}
}
Well, due to the previous UpdateListView code, which uses FileInfo to get information to show all my files!
FileInfo! Lock Files Is it possible?
Can anyone suggest a way around this problem?
Thanks Nando
source
share