Exemple #1
0
 private void GoToAndSelectFileInExplorer(string path)
 {
     //string argument = @"/select" + "\"" + path.Replace('/', '\\') + "\"";
     //string argument = "/select, \"" + path.Replace('/', '\\') + "\"";
     //System.Diagnostics.Process.Start("explorer.exe", argument);
     ShowSelectedInExplorer.FileOrFolder(path);
 }
        void Temp_EV_copyComplete()
        {
            //throw new NotImplementedException();
            if (InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    //Check Open Path
                    DialogResult message = XtraMessageBox.Show("Do you want to open directory?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    try
                    {
                        if (message == DialogResult.Yes)
                        {
                            ShowSelectedInExplorer.FilesOrFolders(this.DestinationPath, this.FilesDownload);
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }));
                return;
            }
        }
Exemple #3
0
        private async void DoExportCollection(object sender, RoutedEventArgs e)
        {
            try {
                string exportFolder = MainWindow.ExportPath;
                string saveName     = ViewModel.CollectionName;
                string savePath     = Path.Combine(exportFolder, saveName + ".zip");

                using (FileStream zipToOpen = new FileStream(savePath, FileMode.OpenOrCreate)) {
                    using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create)) {
                        // Write the save json in the archive
                        var             saveEntryName = Path.Combine(ViewModel.FileHandler.CollectionFolderName, saveName + ".json");
                        ZipArchiveEntry saveEntry     = archive.CreateEntry(saveEntryName);
                        using (StreamWriter writer = new StreamWriter(saveEntry.Open())) {
                            ProjectManager.WriteJson(writer, GetSaveData());
                        }

                        // Add the folder of pattern files
                        foreach (var pattern in ViewModel.Patterns)
                        {
                            var patternFilePath = ViewModel.FileHandler.GetPatternPath(pattern.FileName);
                            var entryName       = ViewModel.FileHandler.GetPatternRelativePath(pattern.FileName);
                            archive.CreateEntryFromFile(patternFilePath, entryName);
                        }
                    }
                }

                await Task.Factory.StartNew(() => MainWindow.MessageQueue.Enqueue("Successfully exported this collection!"));

                ShowSelectedInExplorer.FilesOrFolders(savePath);
            } catch (ArgumentException) { } catch (Exception ex) {
                ex.Show();
            }
        }
 private void ButtonSolverDirectory_Click(object sender, RoutedEventArgs e)
 {
     if (!Directory.Exists(_model.SolverDirectory))
     {
         return;
     }
     ShowSelectedInExplorer.FileOrFolder(_model.SolverDirectory);
 }
Exemple #5
0
 private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (!Directory.Exists(_model.SolverOutputDir))
     {
         return;
     }
     ShowSelectedInExplorer.FileOrFolder(_model.SolverOutputDir);
 }
Exemple #6
0
        private void openInExplorerClick(object sender, EventArgs e)
        {
            string fullPath = _models[_imageIndex].ImageFile.FullPath;

            if (!File.Exists(fullPath))
            {
                return;
            }

            ShowSelectedInExplorer.FilesOrFolders(
                Path.GetDirectoryName(fullPath),
                Array.From(Path.GetFileName(fullPath)));
        }
        private void OpenPath(ICollection <string> files)
        {
            DialogResult message = XtraMessageBox.Show("Do you want to open directory?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            try
            {
                if (message == DialogResult.Yes)
                {
                    ShowSelectedInExplorer.FilesOrFolders(files);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemple #8
0
        public static void OpenFolderAndSelectFile(string fullFilePath)
        {
            try
            {
                /*Process ExplorerWindowProcess = new Process();
                 *
                 * ExplorerWindowProcess.StartInfo.FileName = "explorer.exe";
                 * ExplorerWindowProcess.StartInfo.Arguments = string.Format("/select,\"{0}\"", fullFilePath);
                 *
                 * ExplorerWindowProcess.Start();*/

                ShowSelectedInExplorer.FilesOrFolders(fullFilePath);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private void OpenFileOrFolderLocation(DataGridViewRow row)
        {
            MatchType matchType = (MatchType)row.Cells[ColumnType.Index].Value;
            string    fileName  = (string)row.Cells[ColumnPath.Index].Value;

            if (matchType == MatchType.None)
            {
                return;
            }
            if (matchType == MatchType.File && !File.Exists(fileName))
            {
                return;
            }
            if (matchType == MatchType.Folder && !Directory.Exists(fileName))
            {
                return;
            }


            // Use task to temporarily fix when trying to open unaccessible files/folders
            // It can throw an error after a a minute
            // TODO: find a better solution

            // --> Temp section START

            Exception exception = null;

            Task task = Task.Factory.StartNew(new Action(() =>
            {
                try
                {
                    ShowSelectedInExplorer.FilesOrFolders(Path.GetDirectoryName(fileName), Path.GetFileName(fileName));
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }));

            // --> Temp section END

            // ShowSelectedInExplorer.FilesOrFolders(Path.GetDirectoryName(fileName), Path.GetFileName(fileName));
        }
Exemple #10
0
        static void Main(String[] arguments)
        {
            #region multi instance control
            // çoklu dosya seçiminde her seçilen dosya için bu uygulamadan tekrar çalıştırılır. fakat biz işlemlerimizi ilk çalışan uygulamada bitiriyoruz.
            // uygulamanın tekrar çalıştığını algılayıp (yeni oluşturulan instancelar) bitirilir.
            bool  createdNew;
            Mutex m = new Mutex(true, "myApp", out createdNew);

            if (!createdNew)
            {
                // MessageBox.Show("myApp is already running!", "Multiple Instances");

                return; // Uygulama zaten çalışıyor. O yüzden bunu kapat.
            }

            #endregion

            #region Dosyaların Taşınması
            // Dosya/lar seçildi ise
            if (arguments.Length > 0)
            {
                filePath   = arguments[0];
                folderPath = Path.GetDirectoryName(arguments[0]) + "\\" + Path.GetFileNameWithoutExtension(arguments[0]);

                //- klasör .exe ile bitiyorsa windows oluşturmaya izin vermiyor. o yüzden .exe yi tespit edip .ese ile değiştiriyorum.
                string controlNameExe = Path.GetFileNameWithoutExtension(arguments[0]);
                if (controlNameExe.EndsWith(".exe"))
                {
                    string buff1 = controlNameExe.Remove(controlNameExe.Length - 4, 4) + ".ese";
                    folderPath = Path.GetDirectoryName(arguments[0]) + "\\" + buff1;
                }

                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);                                // Klasör Yoksa Oluştur
                }
                NumberOfSelectedFiles = 0;

                // Seçili Dosyaların Tutuldugu string Koleksiyondan tek tek dosya yolunu al ve yeni oluşturulan klasöre taşı
                foreach (string e1 in FilesAndFolders(Path.GetDirectoryName(arguments[0])))
                {
                    //Gelen Adresin Türünü Belirleme File or Folder
                    FileAttributes attr = File.GetAttributes(e1);

                    if ((attr & FileAttributes.Directory) != FileAttributes.Directory)
                    {// File
                        if (File.Exists(e1))
                        {
                            //MessageBox.Show("Kaynak: "  + e1 + "  ||  Hedef: " + folderPath + "\\" + Path.GetFileName(e1));
                            File.Move(e1, folderPath + "\\" + Path.GetFileName(e1));
                            NumberOfSelectedFiles++;
                        }
                    }
                    else
                    {// Folder
                        if (Directory.Exists(e1) && e1 != folderPath)
                        {
                            //MessageBox.Show("Kaynak: "  + e1 + "  ||  Hedef: " + folderPath);
                            MoveDirectory(e1, folderPath);
                            NumberOfSelectedFiles++;
                        }
                    }
                }

                // Klasör Oluşturulmuş ise Klasörü Seçili ve İsmini Değiştirmeye Hazır Hale Odaklan
                if (Directory.Exists(folderPath))
                {
                    ShowSelectedInExplorer.FilesOrFolders(folderPath); // Klasör Seçildi
                    Console.ReadLine();
                    // F2KeySend();
                }
            }
            else
            {
                // adres argumanı gelmedi ise:
                MessageBox.Show("Dosya Seçilmedi || Not Selected File");
            }

            #endregion
        }