private static ProcessStartInfo LaunchShortcut(string shortcutPath) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.NameSpace(Path.GetDirectoryName(shortcutPath)); bool runAs = IsMarkedRunAs(shortcutPath); string filenameOnly = System.IO.Path.GetFileName(shortcutPath); Shell32.FolderItem folderItem = folder.ParseName(filenameOnly); if (folderItem != null) { Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink; ProcessStartInfo info = new ProcessStartInfo(link.Path, link.Arguments) { WorkingDirectory = link.WorkingDirectory, }; if (runAs) { info.Verb = "runas"; } return(info); } return(null); }
/// <summary> /// Extracts the associated icon for the given file. /// </summary> /// <param name="file"> /// The path of the file to extract the icon from. /// </param> /// <returns> /// A valid icon if the file exists and the icon was extracted succssfully, otherwise null. /// </returns> public static Icon ExtractIcon(string file) { if (string.IsNullOrWhiteSpace(file) || !File.Exists(file)) { return(null); } Icon icon; try { Shell32.Shell shl = new Shell32.Shell(); while (file.ToLower().EndsWith(".lnk")) { Shell32.Folder dir = shl.NameSpace(Path.GetDirectoryName(file)); Shell32.FolderItem itm = dir.Items().Item(Path.GetFileName(file)); Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink; file = lnk.Target.Path; } icon = Icon.ExtractAssociatedIcon(file); } catch (Exception e) { return(Logger.LogReturn <Icon>("Failed extracting icon from \"" + file + "\": " + e.Message, null, LogType.Error)); } return(icon); }
private void outputDirectoryButton_Click(object sender, System.EventArgs e) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.BrowseForFolder(this.Handle.ToInt32(), "Select a directory to share. That directory and all sub-folders will also be made available on the network.", 1, null); string directoryString = null; if (folder != null) { if (folder.ParentFolder != null) { for (int i = 0; i < folder.ParentFolder.Items().Count; i++) { if (folder.ParentFolder.Items().Item(i).IsFolder) { if (((Shell32.Folder)(folder.ParentFolder.Items().Item(i).GetFolder)).Title == folder.Title) { directoryString = folder.ParentFolder.Items().Item(i).Path; break; } } } } if (directoryString == null || directoryString.StartsWith("::") == true) { MessageBox.Show(this, "Invalid folder", "Output Folder", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { outputPathTextBox.Text = directoryString; } } }
/// <summary> /// zipファイルクローズ /// </summary> public void Close() { Sync(); dir = null; sh = null; if (String.Compare(zip, path, true) != 0) { if (File.Exists(path)) { File.Delete(path); } while (true) { try { File.Move(zip, path); break; } catch { Thread.Yield(); Thread.Sleep(500); } } } zip = null; path = null; }
private string GetShortcutInfo(string full_name) { string path = ""; try { Shell32.Shell shell = new Shell32.Shell(); string shortcut_path = full_name.Substring(0, full_name.LastIndexOf("\\")); string shortcut_name = full_name.Substring(full_name.LastIndexOf("\\") + 1); if (!shortcut_name.EndsWith(".lnk")) { shortcut_name += ".lnk"; } Shell32.Folder shortcut_folder = shell.NameSpace(shortcut_path); Shell32.FolderItem folder_item = shortcut_folder.Items().Item(shortcut_name); if (folder_item == null) { if (!folder_item.IsLink) { return("File '" + full_name + "' isn't a shortcut."); } } Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)folder_item.GetLink; path = lnk.Path; return(path); } catch (Exception ex) { return(ex.Message); } }
private void Setup_PreviewPane() { Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart)(() => { if (SelectedItem != null) { if (!Browser.SelectedItems.Any()) { return; } if (this.SelectedItem.IsFolder) { return; } //http://www.codeproject.com/Articles/7987/Retrieve-detailed-information-of-a-File var sh = new Shell32.ShellClass(); Shell32.Folder dir = sh.NameSpace(System.IO.Path.GetDirectoryName(SelectedItem.ParsingName)); Shell32.FolderItem item = dir.ParseName(System.IO.Path.GetFileName(SelectedItem.ParsingName)); // loop through the Folder Items for (int i = 0; i < 30; i++) { // read the current detail Info from the FolderItem Object //(Retrieves details about an item in a folder. For example, its size, type, or the time of its last modification.) // some examples: // 0 Retrieves the name of the item. // 1 Retrieves the size of the item. // 2 Retrieves the type of the item. // 3 Retrieves the date and time that the item was last modified. // 4 Retrieves the attributes of the item. // -1 Retrieves the info tip information for the item. string colName = dir.GetDetailsOf(String.Empty, i); string value = dir.GetDetailsOf(item, i); // Create a helper Object for holding the current Information // an put it into a ArrayList } //this.SelectedItem.Thumbnail.CurrentSize = new System.Windows.Size(this.ActualHeight - 20, this.ActualHeight - 20); //this.SelectedItem.Thumbnail.FormatOption = BExplorer.Shell.Interop.ShellThumbnailFormatOption.Default; //this.SelectedItem.Thumbnail.RetrievalOption = BExplorer.Shell.Interop.ShellThumbnailRetrievalOption.Default; //icon.Source = this.SelectedItem.Thumbnail.BitmapSource; //txtDisplayName.Text = SelectedItem.DisplayName; //txtFileType.Text = "Extension: " + SelectedItem.Extension; //txtPath.Text = "Location : " + SelectedItem.FileSystemPath; //var OpenWirgList = SelectedItem.GetAssocList(); //if (OpenWirgList.Any()) { // txtOpenWith.Text = "Opens With: " + OpenWirgList.First().DisplayName; //} var File = new System.IO.FileInfo(Browser.SelectedItems[0].ParsingName); txtFileSize.Text = "Size: " + File.Length.ToString(); txtFileCreated.Text = "Created: " + File.CreationTime.ToLongDateString(); txtFileModified.Text = "Modified: " + File.LastWriteTime.ToLongDateString(); } })); }
private static void UnZip(string zipFile, string folderPath) //flags above used to configure copy options //4 – Do not display a progress dialog box. //8 – Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists. //16 – Respond with “Yes to All” for any dialog box that is displayed. //64 – Preserve undo information, if possible. //128 – Perform the operation on files only if a wildcard file name(*.*) is specified. //256 – Display a progress dialog box but do not show the file names. //512 – Do not confirm the creation of a new directory if the operation requires one to be created. //1024 – Do not display a user interface if an error occurs. //2048 – Version 4.71. Do not copy the security attributes of the file. //4096 – Only operate in the local directory.Do not operate recursively into subdirectories. //8192 – Version 5.0. Do not copy connected files as a group. Only copy the specified files. { if (!File.Exists(zipFile)) { throw new FileNotFoundException(); } if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } Shell32.Shell objShell = new Shell32.Shell(); Shell32.Folder destinationFolder = objShell.NameSpace(folderPath); Shell32.Folder sourceFile = objShell.NameSpace(zipFile); foreach (var file in sourceFile.Items()) { destinationFolder.CopyHere(file, 16); } }
public void onStartup() { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder objFolder = shell.NameSpace(@"C:\Windows"); this.files.Clear(); foreach (string name in ColumnListPerName) { this.files.Columns.Add(name); } foreach (int id in ColumnListPerID) { string header = objFolder.GetDetailsOf(null, id); if (String.IsNullOrEmpty(header)) { break; } while (this.files.Columns.Contains(header)) { header += "_"; } header = header.Replace("'", "_").Replace("’", "_"); Debug.WriteLine("creating column named " + header); this.files.Columns.Add(header); } this.files.Columns["ID"].DataType = Type.GetType("System.Int32"); this.files.Columns[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")].DataType = Type.GetType("System.Int32"); //this.files.Columns["Longueur"].DataType = Type.GetType("System.TimeSpan"); this.files.Columns["URI"].DataType = typeof(System.Uri); ProcessLibraries(); this.files.AcceptChanges(); }
public frmMain(Shell32.Folder recycle) { InitializeComponent(); worker = new RecycleWorker(recycle); worker.Empty += Worker_Empty; worker.NotEmpty += Worker_NotEmpty; }
/// <summary> /// Get duration(ms) of audio or vedio by Shell32.dll /// </summary> /// <param name="filePath">audio/vedio's path</param> /// <returns>Duration in original format, duration in milliseconds</returns> /// <remarks>return value from Shell32.dll is in format of: "00:10:16"</remarks> public override Tuple <string, long> GetDuration(string filePath) { try { string dir = Path.GetDirectoryName(filePath); // From Add Reference --> COM Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder folder = shell.NameSpace(dir); Shell32.FolderItem folderitem = folder.ParseName(Path.GetFileName(filePath)); string duration = null; // Deal with different versions of OS if (Environment.OSVersion.Version.Major >= 6) { duration = folder.GetDetailsOf(folderitem, 27); } else { duration = folder.GetDetailsOf(folderitem, 21); } duration = string.IsNullOrEmpty(duration) ? "00:00:00" : duration; return(Tuple.Create(duration, GetTimeInMillisecond(duration))); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取MD5和播放时长 /// </summary> /// <param name="FilePathName"></param> /// <returns></returns> public ViewModelVideoItem GetItem(string FilePathName) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = FilePathName.Substring(FilePathName.LastIndexOf("\\") + 1); newItem.ReRelativeUrl = FilePathName; int sum = 0; if (newItem.Name.Substring(newItem.Name.LastIndexOf(".")) == ".wmv" || newItem.Name.Substring(newItem.Name.LastIndexOf(".")) == ".WMV") { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder folder = shell.NameSpace(FilePathName.Substring(0, FilePathName.LastIndexOf("\\"))); Shell32.FolderItem folderitem = folder.ParseName(newItem.Name); string len; if (Environment.OSVersion.Version.Major >= 6) { len = folder.GetDetailsOf(folderitem, 27); } else { len = folder.GetDetailsOf(folderitem, 21); } string[] str = len.Split(new char[] { ':' }); sum = int.Parse(str[0]) * 3600 + int.Parse(str[1]) * 60 + int.Parse(str[2]) + 1; } newItem.SunTime = sum; newItem.MD5Value = SeatManage.SeatManageComm.SeatComm.GetMD5HashFromFile(newItem.ReRelativeUrl); return(newItem); }
/// <summary> /// 长度秒(支持mp4?) /// </summary> /// <param name="path"></param> /// <returns></returns> public static int GetMediaTimeLenSecond(string path) { try { Shell32.Shell shell = new Shell32.Shell(); //文件路径 Shell32.Folder folder = shell.NameSpace(path.Substring(0, path.LastIndexOf("\\"))); //文件名称 Shell32.FolderItem folderitem = folder.ParseName(path.Substring(path.LastIndexOf("\\") + 1)); string len; if (Environment.OSVersion.Version.Major >= 6) { len = folder.GetDetailsOf(folderitem, 27); } else { len = folder.GetDetailsOf(folderitem, 21); } string[] str = len.Split(new char[] { ':' }); int sum = 0; sum = int.Parse(str[0]) * 60 * 60 + int.Parse(str[1]) * 60 + int.Parse(str[2]); return(sum); } catch (Exception ex) { return(0); } }
private void ProcessFile(Shell32.FolderItem file, Shell32.Folder objFolder) { Debug.WriteLine(" [Processing File " + file.Path + "]"); DataRow data = files.NewRow(); foreach (int id in ColumnListPerID) { if (id != 26) { data[objFolder.GetDetailsOf(null, id).Replace("'", "_").Replace("’", "_")] = objFolder.GetDetailsOf(file, id); } } if (string.IsNullOrEmpty(objFolder.GetDetailsOf(file, 26))) { data[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")] = DBNull.Value; } else { data[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")] = int.Parse(objFolder.GetDetailsOf(file, 26)); } if ((string)data[objFolder.GetDetailsOf(null, 21).Replace("'", "_").Replace("’", "_")] == "") { data[objFolder.GetDetailsOf(null, 21).Replace("'", "_").Replace("’", "_")] = System.IO.Path.GetFileName(file.Path); } data["URI"] = new Uri(file.Path); data["ID"] = files.Rows.Count + 1; files.Rows.Add(data); }
/// <summary> /// Get camera manufacturer information. /// </summary> private static ExifInfo GetCameraManufacturer(Shell32.Folder objFolder, Shell32.FolderItem folderItem) { var propertyValue = objFolder.GetDetailsOf(folderItem, 32); var propertyText = "カメラ製造元"; return(new ExifInfo(propertyText, propertyValue)); }
internal static bool IsShortcut(string path) { if (!File.Exists(path)) { return(false); } string directory = Path.GetDirectoryName(path); string file = Path.GetFileName(path); try { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder folder = shell.NameSpace(directory); Shell32.FolderItem folderItem = folder.ParseName(file); if (folderItem != null) { return(folderItem.IsLink); } } catch { } return(false); }
private string GetFileInfo() { // TODO: Add exception-handling. What if file can't be found or is invalid? string dirname; string filename; string header; string data; string info = ""; Shell32.Shell shell = new Shell32.ShellClass(); dirname = Path.GetDirectoryName(trackPath); filename = Path.GetFileName(trackPath); Shell32.Folder folder = shell.NameSpace(dirname); Shell32.FolderItem folderitem = folder.ParseName(filename); info = filename; for (int i = 0; i <= 315; i++) { header = folder.GetDetailsOf(null, i); data = folder.GetDetailsOf(folderitem, i); if (!(String.IsNullOrEmpty(header)) && !(String.IsNullOrEmpty(data))) { info += $"{header}: {data}\r"; } } return(info); }
private static void ChangeLinkTarget(string shortcutFullPath, string newTarget) { // Load the shortcut. Shell32.Folder folder = GetShell32NameSpaceFolder(Path.GetDirectoryName(shortcutFullPath)); Shell32.FolderItems items = folder.Items(); IEnumerator en = items.GetEnumerator(); Shell32.FolderItem item = null; while (en.MoveNext()) { item = en.Current as Shell32.FolderItem; if (item == null) { continue; } if (item.Name == Path.GetFileName(shortcutFullPath)) { break; } } if (item == null || !item.IsLink) { return; } Shell32.ShellLinkObject currentLink = (Shell32.ShellLinkObject)item.GetLink; // Assign the new path here. This value is not read-only. currentLink.Path = newTarget; // Save the link to commit the changes. currentLink.Save(); }
private static void CheckForSubDirs(TreeNode tn, ImageList imageList) { if (tn.Nodes.Count == 0) { try { // create dummy nodes for any subfolders that have further subfolders Shell32.FolderItem folderItem = (Shell32.FolderItem)tn.Tag; Shell32.Folder folder = (Shell32.Folder)folderItem.GetFolder; bool hasFolders = false; foreach (Shell32.FolderItem item in folder.Items()) { if (item.IsFileSystem && item.IsFolder && !item.IsBrowsable) { hasFolders = true; break; } } if (hasFolders) { TreeNode ntn = new TreeNode(); ntn.Tag = "DUMMYNODE"; tn.Nodes.Add(ntn); } } catch {} } }
private string GetFileInfo() { string dirname; string filename; string header; string data; string info = ""; Shell32.Shell shell = new Shell32.Shell(); dirname = Path.GetDirectoryName(trackPath); filename = Path.GetFileName(trackPath); Shell32.Folder folder = shell.NameSpace(dirname); Shell32.FolderItem folderitem = folder.ParseName(filename); info = filename + "\n"; for (int i = 1; i <= 350; i++) { header = folder.GetDetailsOf(null, i); data = folder.GetDetailsOf(folderitem, i); if (!(String.IsNullOrEmpty(header)) && !(String.IsNullOrEmpty(data))) { if (header == "Wolne miejsce" || header == "Całkowity rozmiar") { i++; } else { info += $"{header}: {data}\r"; } } } return(info); }
// ファイルのプロパティからイメージの高さを取得 private int GetFileHeightProperty(string filePath) { Shell32.Shell shell = new Shell32.Shell(); string res = ""; int height = 0; try { Shell32.Folder objFolder = shell.NameSpace(System.IO.Path.GetDirectoryName(filePath)); Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(filePath)); for (int i = 0; i < 300; i++) { if (objFolder.GetDetailsOf("", i) == "高さ") { res = objFolder.GetDetailsOf(folderItem, i); break; } } Regex regex = new Regex("[0-9]+"); Match match = regex.Match(res); if (match.Success) { height = int.Parse(match.Value); } } catch { height = 0; } return(height); }
/// <summary> /// Uses Shell32 /// </summary> /// <param name="siteUrl"></param> /// <param name="filePathPattern">For example, to make a wildcard search ".doc" use the following /// reg expression: Regex regex = new Regex(@".*\.doc", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// to exclude word template documents assigned to a SharePoint workspace, use the following reg /// expression: new Regex(@"(?<!.*/Forms/[^/]+)\.doc$", RegexOptions.Compiled | RegexOptions.IgnoreCase)</param> /// <returns></returns> public static StringCollection CopyFilesFromWebFolderToLocal(Uri siteUrl, string localFolder, bool copySubFolders) { StringCollection ret = new StringCollection(); string mapFolderPath; try { if (!Directory.Exists(localFolder)) { Directory.CreateDirectory(localFolder); } mapFolderPath = CreateWebFolderLink(siteUrl); } catch (Exception e) { return(ret); } Shell32.ShellClass shell = new Shell32.ShellClass(); Shell32.Folder mapFolder = shell.NameSpace(mapFolderPath); Shell32.Folder dsFolder = shell.NameSpace(localFolder); // shell.Explore(mapFolder); // For Debugging (opens up folder in explorer) CopyToFolder(mapFolder, dsFolder, copySubFolders, ref ret); File.Delete(mapFolderPath); return(ret); }
/// <summary> /// Get camera model information. /// </summary> private static ExifInfo GetCameraModel(Shell32.Folder objFolder, Shell32.FolderItem folderItem) { var propertyValue = objFolder.GetDetailsOf(folderItem, 30); var propertyText = "カメラモデル"; return(new ExifInfo(propertyText, propertyValue)); }
/// <summary> /// example: /// NetWork("无线网络连接","禁用") /// NetWork("无线网络连接","启用") /// </summary> /// <param name="netWorkName"></param> /// <param name="operation"></param> static void NetWork(string netWorkName, string operation) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.NameSpace(49); foreach (Shell32.FolderItem fi in folder.Items()) { if (fi.Name != netWorkName) { continue; } Shell32.ShellFolderItem folderItem = (Shell32.ShellFolderItem)fi; foreach (Shell32.FolderItemVerb fiv in folderItem.Verbs()) { if (!fiv.Name.Contains(operation)) { continue; } else { fiv.DoIt(); Thread.Sleep(1000); break; } } } }
private void applyWallpaperWin7(string path) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.NameSpace(Path.GetDirectoryName(path)) as Shell32.Folder; Shell32.FolderItem folderItem = folder.ParseName(System.IO.Path.GetFileName(path)); Shell32.FolderItemVerbs vs = folderItem.Verbs(); bool wallpaperSet = false; for (int i = 0; i < vs.Count; i++) { Shell32.FolderItemVerb ib = vs.Item(i); if (ib.Name.Contains("&b") || ib.Name.Contains("&B")) { if (ib.Name.ToLower().Contains("background") || ib.Name.ToLower().Contains("背景")) { wallpaperSet = true; ib.DoIt(); } } } if (wallpaperSet == false) { applyWallpaperXP(path); } else { downloadAndApplyWallpaperSucceeded(); } }
public void DataReaderSetup(string foldername) { _foldername = foldername; //_objFolder = _shell.NameSpace(@_foldername); _objFolder = _shell.NameSpace(@"C:\Users\Jakob\Music\"); for (int i = 0; i < short.MaxValue; i++) { string header = _objFolder.GetDetailsOf(null, i); if (String.IsNullOrEmpty(header)) break; _arrHeaders.Add(header); } foreach (Shell32.FolderItem2 item in _objFolder.Items()) { for (int i = 0; i < _arrHeaders.Count; i++) //for (int i = 0; i < 50; i++) //this prints the metadata <-- { Console.WriteLine("{0}\t{1}: {2}", i, _arrHeaders[i], _objFolder.GetDetailsOf(item, i)); } } }
private void OnClick_LoadFiles(object sender, RoutedEventArgs e) { string p = ZS_TXT_FolderPath.Text; if (!Directory.Exists(p)) { System.Windows.MessageBox.Show("目录不存在!"); return; } Shell32.ShellClass sh = new Shell32.ShellClass(); Shell32.Folder dir = sh.NameSpace(p); foreach (Shell32.FolderItem item in dir.Items()) { txtTest.Text += "\r\n" + dir.GetDetailsOf(item, 0); txtTest.Text += "\r\n" + dir.GetDetailsOf(item, 1); txtTest.Text += "\r\n" + dir.GetDetailsOf(item, 21); txtTest.Text += "\r\n" + dir.GetDetailsOf(item, 27); } //string[] files = Directory.GetFiles(ZS_TXT_FolderPath.Text); //foreach (string f in files) //{ // Shell32.FolderItem item = dir.ParseName(f); //} sh = null; }
private string GetShortcutInfo(string full_name, out string name, out string path, out string descr, out string working_dir, out string args) { name = ""; path = ""; descr = ""; working_dir = ""; args = ""; try { // Make a Shell object. Shell32.Shell shell = new Shell32.Shell(); // Get the shortcut's folder and name. string shortcut_path = full_name.Substring(0, full_name.LastIndexOf("\\")); string shortcut_name = full_name.Substring(full_name.LastIndexOf("\\") + 1); if (!shortcut_name.EndsWith(".lnk")) { shortcut_name += ".lnk"; } // Get the shortcut's folder. Shell32.Folder shortcut_folder = shell.NameSpace(shortcut_path); // Get the shortcut's file. Shell32.FolderItem folder_item = shortcut_folder.Items().Item(shortcut_name); if (folder_item == null) { return("Cannot find shortcut file '" + full_name + "'"); } if (!folder_item.IsLink) { return("File '" + full_name + "' isn't a shortcut."); } // Display the shortcut's information. Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)folder_item.GetLink; name = folder_item.Name; descr = lnk.Description; if (File.Exists(lnk.Path)) { path = lnk.Path; } else { if (File.Exists(lnk.Path.Replace("(x86)", ""))) { path = lnk.Path.Replace("(x86)", ""); } } working_dir = lnk.WorkingDirectory; args = lnk.Arguments; return(""); } catch (Exception ex) { return(ex.Message); } }
private bool tryGetMediaCreated(FileInfo file, out DateTime mediaCreated) { try { Shell32.Folder folder = GetShell32NameSpaceFolder(file.DirectoryName); Shell32.FolderItem folderItem = folder.ParseName(file.Name); string created = folder.GetDetailsOf(folderItem, 209); string sanitized = ""; foreach (char c in created.ToCharArray()) { if ((int)c < 128) { sanitized += c; } } mediaCreated = DateTime.Parse(sanitized); return(true); } catch (Exception e) { Console.WriteLine("Non-video file type found"); Console.WriteLine(e.ToString()); } mediaCreated = DateTime.MinValue; return(false); }
static void CreateShortcut(string FullFolderPath) { string FolderName = Path.GetFileNameWithoutExtension(FullFolderPath); string FolderDir = Path.GetDirectoryName(FullFolderPath); string FolderRoot = Path.GetPathRoot(FullFolderPath); string lnkPath = Path.Combine(FolderDir, FolderName) + ".lnk"; File.WriteAllBytes(lnkPath, new byte[] { }); Shell32.Shell shl = new Shell32.ShellClass(); Shell32.Folder dir = shl.NameSpace(FolderDir); Shell32.FolderItem itm = dir.Items().Item(FolderName + ".lnk"); Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink; lnk.Path = FolderRoot + "\\execute.bat"; lnk.Description = FolderName; lnk.Arguments = "\"" + FullFolderPath + "\""; lnk.WorkingDirectory = FolderDir; SHFILEINFO shinfo = new SHFILEINFO(); Win32.SHGetFileInfo(FullFolderPath, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), (int)0x1000); lnk.SetIconLocation(shinfo.szDisplayName, shinfo.iIcon); lnk.Save(lnkPath); }
private static Boolean checkStatus(int ItemCount, Shell32.Folder DestFlder) { DateTime timeoutDeadline = DateTime.Now.AddMinutes(1); for (; ;) { //Are we past the deadline? if (DateTime.Now > timeoutDeadline) { break; } //Check the number of items in the new zip to see if it matches //the number of items in the original source location //Only check the item count every .25 seconds System.Threading.Thread.Sleep(250); int ZipFileItemCount = RecurseCount(DestFlder.Items()); if (ItemCount == ZipFileItemCount) { break; } } return(true); }
void PopulateNovelsURLs(ComboBox cb) { List <NovelDrop> items = new List <NovelDrop>(); // Get the shortcut's folder. Shell32.Folder shortcut_folder = _shell.NameSpace(_exe_dir); string[] fileEntries = Directory.GetFiles(_exe_dir); foreach (string file in fileEntries) { if (System.IO.Path.GetExtension(file).Equals(".url", StringComparison.InvariantCultureIgnoreCase)) { //Get the shortcut's file. Shell32.FolderItem folder_item = shortcut_folder.Items().Item(System.IO.Path.GetFileName(file)); // Get shortcut's information. Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)folder_item.GetLink; items.Add(new NovelDrop() { Novel = folder_item.Name, Link = lnk.Path }); } } // Assign data to combobox cb.ItemsSource = items; }
private void FillLocalView(Shell32.Folder folder) { this.Cursor = Cursors.WaitCursor; m_currentFolder = folder; // Notify that update begins LocalView.BeginUpdate(); // Erase last view items LocalView.Items.Clear(); // Erase previous lists image ImgListViewSmall.Images.Clear(); ImgListViewLarge.Images.Clear(); int idImage = 0; ListViewItem lvItem = new ListViewItem(".."); lvItem.Tag = folder; LocalView.Items.Add(lvItem); Shell32.FolderItems items = folder.Items(); // Folder enumeration foreach (Shell32.FolderItem item in items) { if (item.IsFolder) { AddViewItem(item, ref idImage); } } // Other files foreach (Shell32.FolderItem item in items) { if (!item.IsFolder) { AddViewItem(item, ref idImage); } } // End update view LocalView.EndUpdate(); //ftpc.LocalFolder = folder.Title; this.Cursor = Cursors.Default; }
public Main() { InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // SplitView.SplitPosition = this.Width / 2; m_Shell = new Shell32.ShellClass(); m_RootShell = m_Shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDRIVES); InitializeIconFolder(); FillLocalView(m_RootShell); }
public SharpFTP() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // SplitView.SplitPosition = this.Width / 2; m_Shell = new Shell32.ShellClass(); m_RootShell = m_Shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDRIVES); InitializeIconFolder(); FillLocalView (m_RootShell); }
public MediaItem(string Path) { this.Path = Path; Folder = Shell.NameSpace(System.IO.Path.GetDirectoryName(Path)); FolderItem = Folder.ParseName(System.IO.Path.GetFileName(Path)); Execute(); UpdateContainingMedia(); //TraceProperties(); }