예제 #1
0
        private string GetLinkFile(string fileName)
        {
            string linkFile = fileName + ".lnk";

            if (File.Exists(linkFile) == false)
            {
                CSharpLib.Shortcut sc = new CSharpLib.Shortcut();
                sc.CreateShortcutToFile(fileName, linkFile);
            }
            return(linkFile);
        }
        public void Generate(ShortcutRequest shortcutRequest)
        {
            var shortcutPath = Path.Combine(
                shortcutRequest.ShortcutDirectoryPath,
                $"{shortcutRequest.ShortcutName}.lnk");

            if (File.Exists(shortcutPath))
            {
                throw new InvalidOperationException("Shortcut already exists.");
            }

            var shortcut = new CSharpLib.Shortcut();

            shortcut.CreateShortcutToFile(shortcutRequest.SourceFullPath, shortcutPath,
                                          WorkingDirectory: shortcutRequest.WorkingDirectory);
        }