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); 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); }