I don't know if my subject is using the proper terminology, but I am trying to export a file that is displayed in my list view and save it on the windows explorer window. Here are the details:
I have a file that is basically a database of encryptedfiles and directories. I have implemented a viewerwhich displays the contents in a listview. I am able to drag items (folders and files)from a windows explorer window onto the listview and it properly imports the items into the database. I also implemented an export function where I can double-click on an item in the database and it will allow me to export the item to windows explorer.
Now, I am trying to drag items from the list view and drop them into windows explorer and execute an export of those items. I have implemented ItemDrag in this manner...
Code Snippet
private
void listView_ItemDrag(object sender, ItemDragEventArgs e)
{
MessageBox.Show("Item Drag Event");
string[] files = new string[listView.SelectedItems.Count];
int i = 0;
foreach (ListViewItem lvi in listView.SelectedItems)
{
files[i] = lvi.SubItems[4].Text; // Items path in the database
}
if (files != null && files.Length > 0)
{
DoDragDrop(
new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy | DragDropEffects.Move);
}
}
The base.DoDragDrop() function tries to copy the file from one location to the location where the drop occured. Since the origin of the items in my listbox are from this database, we obviously get the appropriate error of "Cannot copy file: Cannot read from the source file or disk." So I have been searching for a way to override the function that attemts to do the file copy (so I can use my own export code), or for a way to override the DoDragDrop() so I can call my own export function (which finds it in the database, decrypts it, and saves it)instead of it's normal file copy or file move function. I haven't been able to find enough information on DoDragDrop to do this.
Does anyone have any insight on this?
Thanks!