Drag Drop copy file
Posted
by
Graham Warrender
on Stack Overflow
See other posts from Stack Overflow
or by Graham Warrender
Published on 2012-09-18T15:18:46Z
Indexed on
2012/09/18
15:37 UTC
Read the original article
Hit count: 245
I've perhaps done something marginally stupid, but can't see what it is!!
string pegasusKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Pegasus\";
string opera2ServerPath = @"Server VFP\";
string opera3ServerPath = @"O3 Client VFP\";
string opera2InstallationPath = null;
string opera3InstallationPath = null;
//Gets the opera Installtion paths and reads to the string opera*InstallationPath
opera2InstallationPath = (string)Registry.GetValue(pegasusKey + opera2ServerPath + "System", "PathToServerDynamic", null);
opera3InstallationPath = (string)Registry.GetValue(pegasusKey + opera3ServerPath + "System", "PathToServerDynamic", null);
string Filesource = null;
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string File in FileList)
Filesource = File;
label.Text = Filesource;
if (System.IO.Directory.Exists(opera3InstallationPath))
{
System.IO.File.Copy(Filesource, opera3InstallationPath);
MessageBox.Show("File Copied from" + Filesource + "\n to" + opera3InstallationPath);
}
else
{
MessageBox.Show("Directory Doesn't Exist");
}
The user drags the file onto the window, I then get the installation path of an application which is then used as the destination for the source file.. When the application is runs, it throws the error directory not found. But surely if the directory doesn't exists is should step into the else statement? a simple application that is becoming a headache!!
© Stack Overflow or respective owner