private void IconGenerator_DoWork(object sender, DoWorkEventArgs e) { var results = new Dictionary <string, string>(); e.Result = results; var targetDir = SharedRoutines.GetIconDirectoryPath(); EnsureDirectoryCreate(targetDir, false); foreach (var eachKey in ImageList.Images.Keys) { var targetPath = Path.Combine(targetDir, eachKey + ".ico"); var fileInfo = new FileInfo(targetPath); if (fileInfo.Exists && fileInfo.Length > 0L) { continue; } var creationResult = ImagingHelper.ConvertToIcon(ImageList.Images[eachKey], fileInfo.FullName); if (!creationResult) { results.Add(eachKey, targetPath); } } }
private bool CreateDistroShortcut(DistroProperties selectedDistro, string targetFilePath) { var shortcut = (IWshShortcut)wscriptShellType.InvokeMember( "CreateShortcut", BindingFlags.InvokeMethod, null, shellObject, new object[] { targetFilePath }); shortcut.Description = selectedDistro.DistroName; shortcut.TargetPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), "wsl.exe"); shortcut.WorkingDirectory = Environment.GetFolderPath( Environment.SpecialFolder.UserProfile); shortcut.Arguments = $@"-d {selectedDistro.DistroName}"; shortcut.IconLocation = Path.Combine( SharedRoutines.GetIconDirectoryPath(), SharedRoutines.GetImageKey(selectedDistro.DistroName) + ".ico"); shortcut.Save(); return(File.Exists(targetFilePath)); }