<i id='5NZsu'><tr id='5NZsu'><dt id='5NZsu'><q id='5NZsu'><span id='5NZsu'><b id='5NZsu'><form id='5NZsu'><ins id='5NZsu'></ins><ul id='5NZsu'></ul><sub id='5NZsu'></sub></form><legend id='5NZsu'></legend><bdo id='5NZsu'><pre id='5NZsu'><center id='5NZsu'></center></pre></bdo></b><th id='5NZsu'></th></span></q></dt></tr></i><div id='5NZsu'><tfoot id='5NZsu'></tfoot><dl id='5NZsu'><fieldset id='5NZsu'></fieldset></dl></div>
    <legend id='5NZsu'><style id='5NZsu'><dir id='5NZsu'><q id='5NZsu'></q></dir></style></legend>

    <tfoot id='5NZsu'></tfoot>

    1. <small id='5NZsu'></small><noframes id='5NZsu'>

        <bdo id='5NZsu'></bdo><ul id='5NZsu'></ul>

    2. WPF:将虚拟文件拖放到 Windows 资源管理器中

      时间:2023-08-25
        <tbody id='QcovJ'></tbody>

          <tfoot id='QcovJ'></tfoot>

            <small id='QcovJ'></small><noframes id='QcovJ'>

            <i id='QcovJ'><tr id='QcovJ'><dt id='QcovJ'><q id='QcovJ'><span id='QcovJ'><b id='QcovJ'><form id='QcovJ'><ins id='QcovJ'></ins><ul id='QcovJ'></ul><sub id='QcovJ'></sub></form><legend id='QcovJ'></legend><bdo id='QcovJ'><pre id='QcovJ'><center id='QcovJ'></center></pre></bdo></b><th id='QcovJ'></th></span></q></dt></tr></i><div id='QcovJ'><tfoot id='QcovJ'></tfoot><dl id='QcovJ'><fieldset id='QcovJ'></fieldset></dl></div>

            • <bdo id='QcovJ'></bdo><ul id='QcovJ'></ul>

              • <legend id='QcovJ'><style id='QcovJ'><dir id='QcovJ'><q id='QcovJ'></q></dir></style></legend>
              • 本文介绍了WPF:将虚拟文件拖放到 Windows 资源管理器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在开发一个类似于 dropbox 的应用程序,并在 WPF 列表视图中显示远程文件.我想将这些元素拖放到 Windows 资源管理器中.我见过这样的代码:

                I'm developing an application similar to dropbox and i show the remote files on a WPF listview. I want to drag those elements and drop it into windows explorer. I've seen code like this:

                var dataObject = new DataObject(DataFormats.FileDrop, files.ToArray());
                dataObject.SetData(DataFormats.StringFormat, dataObject);
                DoDragDrop(dataObject, DragDropEffects.Copy);
                

                但正如您可能认为的那样,这些文件还没有在本地系统中,在复制它们之前,我需要连接到服务器,下载并解压缩文件.就像 ftp 客户端一样.

                But as you may think, those file are not at the local system yet, before copiying them I need to connect to server, donwload and unzip the files. Like a ftp client does.

                我不知道怎么做,但我想知道是否有任何drop"事件或类似的我可以处理.

                I dont how to do it but i was wondering if there is any "drop" event or similiar that i can handle.

                谢谢!

                推荐答案

                这段代码:

                var virtualFileDataObject = new VirtualFileDataObject(
                                // BeginInvoke ensures UI operations happen on the right thread
                                (vfdo) => Dispatcher.BeginInvoke((Action)(() => BusyScreen.Visibility = Visibility.Visible)),
                                (vfdo) => Dispatcher.BeginInvoke((Action)(() => BusyScreen.Visibility = Visibility.Collapsed)));
                
                            // Provide a virtual file (downloaded on demand), its URL, and descriptive text
                            virtualFileDataObject.SetData(new VirtualFileDataObject.FileDescriptor[]
                            {
                                new VirtualFileDataObject.FileDescriptor
                                {
                                    Name = "DelaysBlog.xml",
                                    StreamContents = stream =>
                                        {
                                            using(var webClient = new WebClient())
                                            {
                                                var data = webClient.DownloadData("http://blogs.msdn.com/delay/rss.xml");
                                                stream.Write(data, 0, data.Length);
                                            }
                                        }
                                },
                            });
                            virtualFileDataObject.SetData(
                                (short)(DataFormats.GetDataFormat(CFSTR_INETURLA).Id),
                                Encoding.Default.GetBytes("http://blogs.msdn.com/delay/rss.xml"));
                            virtualFileDataObject.SetData(
                                (short)(DataFormats.GetDataFormat(DataFormats.Text).Id),
                                Encoding.Default.GetBytes("[The RSS feed for Delay's Blog]"));
                
                            DoDragDropOrClipboardSetDataObject(e.ChangedButton, TextUrl, virtualFileDataObject, DragDropEffects.Copy);
                

                使用类 linked 应该可以工作..非常好的和简单的解决方案.

                Using the class linked should work. . Very nice and easy solution.

                这篇关于WPF:将虚拟文件拖放到 Windows 资源管理器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:DoDragDrop 禁用 MouseMove 事件 下一篇:C# 在 Canvas 中拖放图像

                相关文章

                最新文章

                <legend id='0pqmd'><style id='0pqmd'><dir id='0pqmd'><q id='0pqmd'></q></dir></style></legend>
                  <bdo id='0pqmd'></bdo><ul id='0pqmd'></ul>

                  <small id='0pqmd'></small><noframes id='0pqmd'>

                  1. <i id='0pqmd'><tr id='0pqmd'><dt id='0pqmd'><q id='0pqmd'><span id='0pqmd'><b id='0pqmd'><form id='0pqmd'><ins id='0pqmd'></ins><ul id='0pqmd'></ul><sub id='0pqmd'></sub></form><legend id='0pqmd'></legend><bdo id='0pqmd'><pre id='0pqmd'><center id='0pqmd'></center></pre></bdo></b><th id='0pqmd'></th></span></q></dt></tr></i><div id='0pqmd'><tfoot id='0pqmd'></tfoot><dl id='0pqmd'><fieldset id='0pqmd'></fieldset></dl></div>

                  2. <tfoot id='0pqmd'></tfoot>