开发者

How to stop WPF drag and drop from locking dropped file

开发者 https://www.devze.com 2023-02-14 06:51 出处:网络
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 ac

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

0

精彩评论

暂无评论...
验证码 换一张
取 消