Exemplo n.º 1
0
        public void CreateDirectoryShortcut()
        {
            using (var targetPath = new SIL.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                using (var directory = new SIL.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                {
                    ShortcutMaker.CreateDirectoryShortcut(targetPath.Path, directory.Path);

                    var expectedFile = Path.Combine(directory.Path, Path.GetFileName(targetPath.Path)) + ".lnk";
                    Assert.That(File.GetAttributes(expectedFile) & (FileAttributes.Directory | FileAttributes.Normal), Is.Not.Null);
                    Assert.That(ResolveShortcut.Resolve(expectedFile), Is.EqualTo(targetPath.Path));
                }
        }
        public void CreateDirectoryShortcut_FileExists()
        {
            using (var targetPath = new Palaso.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                using (var directory = new Palaso.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                {
                    var existingDestination = new Palaso.TestUtilities.TempFileFromFolder(directory,
                                                                                          Path.GetFileName(targetPath.Path) + ".lnk", string.Empty);

                    ShortcutMaker.CreateDirectoryShortcut(targetPath.Path, directory.Path);

                    var expectedFile = Path.Combine(directory.Path, Path.GetFileName(targetPath.Path)) + ".lnk";
                    Assert.That(File.GetAttributes(expectedFile) & (FileAttributes.Directory | FileAttributes.Normal), Is.Not.Null);
                    Assert.That(ResolveShortcut.Resolve(expectedFile), Is.EqualTo(targetPath.Path));
                }
        }
Exemplo n.º 3
0
 /// <summary>
 /// The idea here is that if someone is editing a shell collection, then next thing they are likely to do is
 /// open a vernacular library and try it out.  By adding this link, well they'll see this collection like
 /// they probably expect.
 /// </summary>
 private void AddShortCutInComputersBloomCollections(string vernacularCollectionDirectory)
 {
     if (!Directory.Exists(ProjectContext.GetInstalledCollectionsDirectory()))
     {
         return;                //well, that would be a bug, I suppose...
     }
     try
     {
         ShortcutMaker.CreateDirectoryShortcut(vernacularCollectionDirectory, ProjectContext.GetInstalledCollectionsDirectory());
     }
     catch (ApplicationException e)
     {
         ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), e.Message);
     }
     catch (Exception e)
     {
         ErrorReport.NotifyUserOfProblem(e,
                                         "Could not add a link for this shell library in the user collections directory");
     }
 }
Exemplo n.º 4
0
 public static void Main(string[] args)
 {
     ShortcutMaker.CreateShortcutByCom(@"notepad.lnk", @"C:\Windows\System32\notepad.exe", "shell32.dll, 5");
     ShortcutMaker.CreateShortcutByWsh(@"notepad.lnk", @"C:\Windows\System32\notepad.exe", "shell32.dll, 5");
     ShortcutMaker.CreateShortcutByClsid(@"notepad.lnk", @"C:\Windows\System32\notepad.exe", "shell32.dll, 5");
 }