private static void HandleDragDrop(object sender, DragEventArgs e)
 {
     new Thread((ThreadStart)(() => FileImporter.HandleDragDropAsync(e, sender as MainWindow)))
     {
         IsBackground = true
     }.Start();
 }
        private static void HandleDragDropAsync(DragEventArgs evt, MainWindow window)
        {
            string mVmName = window.mVmName;

            if (!FileImporter.IsSharedFolderEnabled(window.EngineInstanceRegistry.FileSystem))
            {
                return;
            }
            try
            {
                Array         data1      = (Array)evt.Data.GetData(DataFormats.FileDrop);
                List <string> stringList = new List <string>();
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                for (int index = 0; index < data1.Length; ++index)
                {
                    string path     = data1.GetValue(index).ToString();
                    string fileName = Path.GetFileName(path);
                    if (string.Equals(Path.GetExtension(path), ".apk", StringComparison.InvariantCultureIgnoreCase) || string.Equals(Path.GetExtension(path), ".xapk", StringComparison.InvariantCultureIgnoreCase))
                    {
                        stringList.Add(path);
                    }
                    else
                    {
                        dictionary.Add(fileName, path);
                    }
                }
                string sharedFolderDir = RegistryStrings.SharedFolderDir;
                if (dictionary.Count > 0)
                {
                    string randomBstSharedFolder = Utils.CreateRandomBstSharedFolder(sharedFolderDir);
                    string path1 = Path.Combine(RegistryStrings.SharedFolderDir, randomBstSharedFolder);
                    Logger.Info("Shared Folder path : " + path1);
                    foreach (KeyValuePair <string, string> keyValuePair in dictionary)
                    {
                        Logger.Info("DragDrop File: {0}", (object)keyValuePair.Key);
                        string str = Path.Combine(path1, keyValuePair.Key);
                        try
                        {
                            FileSystem.CopyFile(keyValuePair.Value, str, UIOption.AllDialogs);
                            File.SetAttributes(str, FileAttributes.Normal);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("Failed to copy file : " + keyValuePair.Value + "...Err : " + ex.ToString());
                        }
                    }
                    JArray  jarray1 = new JArray();
                    JObject jobject = new JObject();
                    jobject.Add((object)new JProperty("foldername", (object)randomBstSharedFolder));
                    jarray1.Add((JToken)jobject);
                    JArray jarray2 = jarray1;
                    Dictionary <string, string> data2 = new Dictionary <string, string>()
                    {
                        {
                            "data",
                            jarray2.ToString(Formatting.None)
                        }
                    };
                    Logger.Info("Sending drag drop request: " + jarray2.ToString());
                    try
                    {
                        HTTPUtils.SendRequestToGuest("fileDrop", data2, mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to send FileDrop request. err: " + ex.ToString());
                    }
                }
                if (stringList.Count <= 0)
                {
                    return;
                }
                foreach (string str in stringList)
                {
                    try
                    {
                        HTTPUtils.SendRequestToClient("dragDropInstall", new Dictionary <string, string>()
                        {
                            {
                                "filePath",
                                str
                            }
                        }, mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
                    }
                    catch (Exception ex)
                    {
                        Logger.Warning("Failed to send drag drop install. Err: " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error in DragDrop function: " + ex.Message);
            }
        }