How to stop WPF drag and drop from locking dropped file
I have a drag and drop application (which allows users to organize their files) that takes files. The app keeps a list of strings that corresponds to the files, but i开发者_如何学运维t does not need access to the files themselves. The problem is that the program locks files like the application has them open. How can I release them?
private void File_Dropped(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
return;
var files = e.Data.GetData(DataFormats.FileDrop, true) as string[];
ImageFile iFile;
foreach (var file in files)
{
if (_Extensions.Contains(IO.Path.GetExtension(file).ToUpper()))
{
iFile = new ExtendedImageFile(new StringBuilder(file).ToString());
LBXFiles.Items.Add(iFile);
}
}
e.Handled = true;
}
Fantastic fix lived up to his name. See the commend on the original post
精彩评论