private void FindFieldContent() { textBoxTitle.Text = FindTaskParts(out string[] titles, out string[][] subtasks); Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder folder = shell.NameSpace(FIELD_PIC_PATH); Shell32.FolderItems items = folder.Items(); for (int i = 0; i < items.Count; i++) { var fileName = folder.GetDetailsOf(items.Item(i), 0); DecompilePicName(Path.GetFileNameWithoutExtension(fileName), out var position, out var taskNumber); fields[position - 1].TaskNumbers.Add(taskNumber); fields[position - 1].Title = titles[position - 1]; if (subtasks[position - 1].Length < taskNumber) { MessageBox.Show("Nem tartozik feladat a képhez:" + fileName); fields[position - 1].Tasks.Add(""); } else { fields[position - 1].Tasks.Add(subtasks[position - 1][taskNumber - 1]); } fields[position - 1].Paths.Add(FIELD_PIC_PATH + fileName); } }
private static void UnzipFileToFolderWindows(string zipFilePath, string destinationFolder) { const bool showProgress = false; const bool yesToAll = true; Shell32.Folder fromFolder = GetShell32NameSpace(zipFilePath); Directory.CreateDirectory(destinationFolder); Shell32.Folder toFolder = GetShell32NameSpace(destinationFolder); Shell32.FolderItems sourceFolderItems = fromFolder.Items(); Shell32.FolderItems itemsToExtract; //if the zip file contains a single directory, extract that directory's contents if ((sourceFolderItems.Count == 1) && (sourceFolderItems.Item(0).GetFolder is Shell32.Folder)) { Shell32.FolderItem rootItem = sourceFolderItems.Item(0); itemsToExtract = ((Shell32.Folder)rootItem.GetFolder).Items(); } else { itemsToExtract = sourceFolderItems; } int options = 0; if (!showProgress) { options += 4; } if (yesToAll) { options += 16; } toFolder.CopyHere(itemsToExtract, options); }
private static Shell32.FolderItem ReadFileInfo() { IntPtr handle = GetForegroundWindow(); List <string> selected = new List <string>(); SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass(); foreach (SHDocVw.ShellBrowserWindow window in shellWindows) { if (window.HWND == (int)handle) { Shell32.FolderItems items = ((Shell32.IShellFolderViewDual2)window.Document).SelectedItems(); if (items.Count == 1) { return(items.Item(0)); } } } return(null); }
private static void UnzipFileToFolderWindows(string zipFilePath, string destionationFolder) { const bool showProgress = false; const bool yesToAll = true; Shell32.Folder sourceFolder = GetShell32NameSpace(zipFilePath); Directory.CreateDirectory(destionationFolder); Shell32.Folder destinationFolder = GetShell32NameSpace(destionationFolder); Shell32.FolderItems sourceFolderItems = sourceFolder.Items(); Shell32.FolderItem rootItem = sourceFolderItems.Item(0); int options = 0; if (!showProgress) { options += 4; } if (yesToAll) { options += 16; } destinationFolder.CopyHere(((Shell32.Folder)rootItem.GetFolder).Items(), options); }