private void AddNewItem() { NewItem newItem = new NewItem(); this.InsertItem(newItem, 0); newItem.AddNewItem += (sender, e) => { using (NewLnkFileDialog dlg = new NewLnkFileDialog()) { dlg.FileFilter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.vbs;*.vbe;*.js;*.jse;*.wsf"; if (dlg.ShowDialog() != DialogResult.OK) { return; } string lnkPath = $@"{SendToPath}\{ObjectPath.RemoveIllegalChars(dlg.ItemText)}.lnk"; lnkPath = ObjectPath.GetNewPathWithIndex(lnkPath, ObjectPath.PathType.File); using (ShellLink shellLink = new ShellLink(lnkPath)) { shellLink.TargetPath = dlg.ItemFilePath; shellLink.WorkingDirectory = Path.GetDirectoryName(dlg.ItemFilePath); shellLink.Arguments = dlg.Arguments; shellLink.Save(); } DesktopIni.SetLocalizedFileNames(lnkPath, dlg.ItemText); this.InsertItem(new SendToItem(lnkPath), 2); } }; }
private void AddNewItem() { FilePath = $@"{SendToList.SendToPath}\{ObjectPath.RemoveIllegalChars(ItemText)}.lnk"; FilePath = ObjectPath.GetNewPathWithIndex(FilePath, ObjectPath.PathType.File); IWshRuntimeLibrary.IWshShortcut shortcut = WshShell.CreateShortcut(FilePath); shortcut.TargetPath = ItemCommand; if (rdoFile.Checked) { shortcut.WorkingDirectory = Path.GetDirectoryName(ItemCommand); } shortcut.Save(); DesktopIniHelper.SetLocalizedFileName(FilePath, ItemText); }
private void AddNewItem() { FilePath = $@"{SendToList.SendToPath}\{ObjectPath.RemoveIllegalChars(ItemText)}.lnk"; FilePath = ObjectPath.GetNewPathWithIndex(FilePath, ObjectPath.PathType.File); WshShortcut shortcut = new WshShortcut { FullName = FilePath, TargetPath = Command, WorkingDirectory = Path.GetDirectoryName(Command), Arguments = Arguments }; shortcut.Save(); SendToList.DesktopIniWriter.SetValue("LocalizedFileNames", Path.GetFileName(FilePath), ItemText); }
public DeleteMeMenuItem(ITsiDeleteItem item) : base(AppString.Menu.Delete) { this.Click += (sender, e) => { if (MessageBoxEx.Show(AppString.MessageBox.ConfirmDeletePermanently, MessageBoxButtons.YesNo) == DialogResult.Yes) { if (item is ITsiRegDeleteItem regItem && AppConfig.AutoBackup) { string date = DateTime.Today.ToString("yyyy-MM-dd"); string fileName = ObjectPath.RemoveIllegalChars(regItem.ItemText); string filePath = $@"{AppConfig.BackupDir}\{date}\{fileName}.reg"; filePath = ObjectPath.GetNewPathWithIndex(filePath, ObjectPath.PathType.File); Directory.CreateDirectory(Path.GetDirectoryName(filePath)); RegistryEx.Export(regItem.RegPath, filePath); } item.DeleteMe(); } }; }
private void AddNewItem() { FilePath = $@"{SendToList.SendToPath}\{ObjectPath.RemoveIllegalChars(ItemText)}.lnk"; FilePath = ObjectPath.GetNewPathWithIndex(FilePath, ObjectPath.PathType.File); IWshRuntimeLibrary.IWshShortcut shortcut = WshShell.CreateShortcut(FilePath); if (rdoFile.Checked) { ItemCommand = Environment.ExpandEnvironmentVariables(ItemCommand); shortcut.TargetPath = ObjectPath.ExtractFilePath(ItemCommand, out string shortPath); string str = ItemCommand.Substring(ItemCommand.IndexOf(shortPath) + shortPath.Length); shortcut.Arguments = str.Substring(str.IndexOf(" ") + 1); shortcut.WorkingDirectory = Path.GetDirectoryName(shortcut.TargetPath); } else { shortcut.TargetPath = ItemCommand; } shortcut.Save(); DesktopIniHelper.SetLocalizedFileName(FilePath, ItemText); }