How to simulate a windows explorer?


We would like extract video content from an editing tool using his existing drag&drop function. This Editing tool is able to export content (automatically converted in good format) if destination is a specific windows folder. You can do that with right-click and export menu (Save As …) or just with a Drag&Drop in on a windows folder.

To keep control on these exports in our workflow, we would like create a small “OnTop” application and allow user to drag&drop videocontent from Editing tool (external application) on this small application. But to trig the Editing tool (to fake an export to Windows folder), we have to simulate “Windows Explorer” container.

Any idea ?  
Who is Participating?
ricovoxConnect With a Mentor Commented:
Hi. What you want to do is provide an OLE Drop target. This will allow you to drag and drop files from your editing program (or any other program that is an OLE drop source provider, including windows explorer and many others).

You can do this very simply by setting the "AllowDrop" property of a System.Windows.Forms Control to true and then implementing event handlers for the Drag/Drop events.

Now, OLE drag/drop can be quite complicated, because programs can provide Data objects in many different formats--even custom, non-standard formats. So there is not a 100% guarantee you will be able to easily consume the Data objects provided by your editing program.

However, it is quite likely that your editing program does use one of the standard formats, such as "FileDrop", so you should be able to do what you want.

I have developed a small test application for you. You can use it do find out what formats can be dragged & dropped from your editing application. If it uses the standard "FileDrop" format, I have already even written the code necessary to automatically copy the exported files to a folder of your choice.

Here is a screenshot of the program in action:
Test Program Main Window
For convenience I have listed the content of the main form below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace OleDropTest {
	public partial class TestForm : Form {
		public TestForm() {
			grpDrop.AllowDrop = true;

		private void grpDrop_DragEnter(object sender, DragEventArgs e) {
			StringBuilder info = new StringBuilder();
			e.Effect = e.AllowedEffect & DragDropEffects.Copy;

			string[] formats = e.Data.GetFormats(false);

			info.AppendFormat("Operations: {0}\r\n\r\nFormats:\r\n{1}", e.AllowedEffect, string.Join("\r\n", formats));

			if (Array.IndexOf(formats, DataFormats.FileDrop) != -1) {
				string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
				info.AppendFormat("\r\n\r\nFiles:\r\n{0}", string.Join("\r\n", fileNames));

			txtInfo.Text = info.ToString();

		private void grpDrop_DragDrop(object sender, DragEventArgs e) {
			//if the drop operation is complete, attempt to copy the files.
			try {
				string[] dropFilePaths = (string[])e.Data.GetData(DataFormats.FileDrop);

				e.Effect = DragDropEffects.None; //unless we change it below.

				//make sure the checkbox is checked and that the data contains files.
				if (!chkCopyFiles.Checked | dropFilePaths == null)

				string dstFolder = txtFolder.Text;
				if (!Directory.Exists(dstFolder)) {
					MessageBox.Show("The specified destination folder does not exist.");
					e.Effect = DragDropEffects.None;

				//copy the files or folders
				CopyPathItems(dropFilePaths, dstFolder);
			} catch (Exception ex) {
				MessageBox.Show("Drop Error: " + ex.Message);

		static void CopyPathItems(string[] srcPaths, string dstFolder) {
			if (!Directory.Exists(dstFolder)) Directory.CreateDirectory(dstFolder);

			foreach (string srcPath in srcPaths) {
				string name = Path.GetFileName(srcPath);
				string newPath = Path.Combine(dstFolder, name);
				if (Directory.Exists(srcPath)) //srcPath is a folder. recursively copy all sub-items
					CopyPathItems(Directory.GetFileSystemEntries(srcPath), newPath);
				else //srcPath is a file
					File.Copy(srcPath, newPath);


Open in new window

And you can download the full project for testing here:

Instructions for use:

Run the program and attempt to drag and drop from another application onto the designated drop area.

When you initially drag over the box, you will see information about the dragged data. This includes the allowable operations (such as Move, Copy, Link etc).

It will also list all of the available data formats that can be dropped.

If the available formats includes the "FileDrop" format, it also lists all available files and folders that can be dropped.

When you release the mouse button, the dragged data will be "dropped". If you have checked the "Copy Files To" box and you have specified a valid destination folder, then all available files will be copied into that folder.

If however, your application does NOT have the "FileDrop" format, there are still a number of other formats that can be used, including the "FileName" format. You will just need to post the list of available formats back here and I will take a look to see what we can do to move forward.

Good luck!
BTW, That project contains full C# source code in a VS2008 project.
If you cannot open or compile it, I can provide a download link for the executable for testing.
Dnx_7Author Commented:
Thank you Ricovox but this is a basic drag & drop implementation and of course as you said, it works with any files coming from external files but the problem is that the item dragging from the external program only react when we drop the item in the windows explorer that's why we have to create something like the windows explorer.

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi Dnx,

Have you tested the program I sent?
It not only works with File drag & drop, but from applications also.

My application isn't just specific for file drag & drop. It is a general solution. This is how all OLE drag & drop works. So even if your editing application doesn't expose the files directly, you should still be able to use OLE techniques to get your export  to work. The process of exporting your editing data to Windows Explorer uses the same techniques

For example, you can open a zip file and drag items from the archive onto my program. Even though they are not actual files in the file system, they will still work because the archive program creates the files on-the-fly when the drop occurs. I have tested this with 7-zip and it works great.

I assume your editing application works the same. Once the drop operation occurs, it will write the file to a specified location and it will notify my program of that location.

It will also work with other types of data. You just have to know what the data object format is.

Can you please try the drag & drop from your editing application and list the output from my application here? It is important to see which operations are supported and to find the list of data formats that are supported.
Perhaps your editing program expects the "Move" operation instead of the "Copy" operation that my program uses.
Can you please tell me which editing program you use?
Is it something I can download to see the behavior your discussing?
As another example: You can drag an image from a webpage and drop it onto my application, and it will save the image file to the specified folder.
Dnx_7Author Commented:
Thank you for your help and explanation Ricovox
and yes, i tested your test project and it doesn't trigger like we drop onto the windows explorer.

it is an external application made for broadcast systems and i cannot send the application since it's very huge and need database/servers etc...

btw, to be simple, we need to create a window/control to act like the windows explorer because when we drop the item (from the extenal application) it reacts only when we drop into a windows explorer and nothing else...
CodeCruiserConnect With a Mentor Commented:
Use this Shell Extensions Viewer to see if there is an extension installed by that software.
Dnx_7Author Commented:
Hi, there is nothing installed in the windows shell
For example, i use a webbrowser and set the URL to "C:\" then it becomes a "windows explorer"
i dragged the item and it reacts as we want it to reacts
Windows Explorer has a pluggable architecture. Developers can develop their own extensions for the explorer to handle stuff different. Drop targets is one class of those extensions. Did you try the viewer?
Hi Dnx_7

I understand what you are saying about trying to simulate a Windows Explorer folder window because your program recognizes that for the export. But what we need to figure out is exactly WHAT needs to be simulated. That is, we need to find out exactly how your program "knows" what the drop target is.

I assumed that your program is using OLE drag & drop, because that is a standard technology. If that is true, we should be able to figure out how to trick your application into thinking you are dropping on windows explorer.

However your application COULD be doing something completely NON-standard. For example, it is possible for your application to monitor what type of window is below the mouse cursor (by using APIs like WindowFromPoint, GetWindowInfo, GetClassName, etc) and it exports only when the window is the SysListView32 or SysTreeView32 type used in windows explorer.

But I HIGHLY doubt that is the case. OLE drag & drop is so easy for developers to implement, that I really don't think they would have done something non-standard like that in your external program.

Can you please answer the following questions, so I can think of some alternative methods we can use to test what your program is doing:

1)  When you did drag & drop onto my application from your editing program, did you see ANYTHING appear in the information textbox? (Such as the Operation and Formats list?)

2) What operating system are you using, and what CPU architecture (32 or 64 bit)?
Can you test out your program on a Windows 7 machine? I'm asking because some "Explorer Windows" in Windows 7 are NOT the standard explorer windows found in XP and 2000. So we can see if your program will still work with the new windows that do not have the same window classes as the old ones.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.