示例#1
0
        private void BtnCreateSymbLinks_Click(object sender, RoutedEventArgs e)
        {
            var symblist = ModList
                           .Where(c => c.Source == SourceEnum.Steam && !c.HasSymbLink && c.Selected)
                           .Select(c => new Tuple <string, string>(
                                       System.IO.Path.Combine(LoadService.config.ModFolder, System.IO.Path.GetFileNameWithoutExtension(c.FilePath)),
                                       System.IO.Path.GetDirectoryName(c.FilePath)
                                       )
                                   );

            if (!symblist.Any())
            {
                return;
            }

            var logging = Task.Run(() =>
            {
                var appendLog = new List <string> {
                    $"{DateTime.Now} - Trying to Create SymbLinks:"
                };

                appendLog.Add($"{DateTime.Now} - Detailed List:");
                appendLog.AddRange(symblist.Select(item => $"{DateTime.Now} From {item.Item2} To {item.Item1}:"));

                File.AppendAllLines(Constants.Logfile, appendLog);
            });

            LoadService.CreateSymbLink(symblist);

            logging.Wait();
            LoadModList();
        }
示例#2
0
        public void ExecuteSymbLink(bool ShouldDelete = true, bool ShouldAdd = true)
        {
            var symblist = new List <Tuple <string, string> >();

            foreach (ModFolder mod in ListBox.SelectedItems)
            {
                if (mod.HasSymbLink)
                {
                    if (ShouldDelete)
                    {
                        LoadService.DeleteFolder(System.IO.Path.Combine(LoadService.config.ModFolder, System.IO.Path.GetFileNameWithoutExtension(mod.FilePath)));
                    }
                }
                else
                {
                    if (ShouldAdd)
                    {
                        symblist.Add(new Tuple <string, string>(
                                         System.IO.Path.Combine(LoadService.config.ModFolder, System.IO.Path.GetFileNameWithoutExtension(mod.FilePath)),
                                         System.IO.Path.GetDirectoryName(mod.FilePath)
                                         ));
                    }
                }
            }

            try
            {
                if (!symblist.Any())
                {
                    return;
                }

                var appendLog = new List <string> {
                    $"{DateTime.Now} - Trying to Create SymbLinks:"
                };

                appendLog.Add($"{DateTime.Now} - Detailed List:");
                appendLog.AddRange(symblist.Select(item => $"{DateTime.Now} From {item.Item2} To {item.Item1}:"));

                Logging.Write(Constants.Logfile, appendLog);
            }
            catch (Exception ex)
            {
                Logging.Write(Constants.Errorfile, "Failed to write log of symblinks.");
                Logging.Write(Constants.Errorfile, ex);
            }

            LoadService.CreateSymbLink(symblist, out string message);
            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }
        }
示例#3
0
        private void ExecuteSymbLink(bool ShouldDelete = true, bool ShouldAdd = true)
        {
            var symblist = new List <Tuple <string, string> >();

            foreach (ModFolder mod in ListBox.SelectedItems)
            {
                if (mod.HasSymbLink)
                {
                    if (ShouldDelete)
                    {
                        LoadService.DeleteFolder(System.IO.Path.Combine(LoadService.config.ModFolder, System.IO.Path.GetFileNameWithoutExtension(mod.FilePath)));
                    }
                }
                else
                {
                    if (ShouldAdd)
                    {
                        symblist.Add(new Tuple <string, string>(
                                         System.IO.Path.Combine(LoadService.config.ModFolder, System.IO.Path.GetFileNameWithoutExtension(mod.FilePath)),
                                         System.IO.Path.GetDirectoryName(mod.FilePath)
                                         ));
                    }
                }
            }


            try
            {
                if (!symblist.Any())
                {
                    return;
                }

                var appendLog = new List <string> {
                    $"{DateTime.Now} - Trying to Create SymbLinks:"
                };

                appendLog.Add($"{DateTime.Now} - Detailed List:");
                appendLog.AddRange(symblist.Select(item => $"{DateTime.Now} From {item.Item2} To {item.Item1}:"));

                File.AppendAllLines(Constants.Logfile, appendLog);
            }
            catch (Exception ex)
            {
                File.AppendAllText(Constants.Errorfile, $"{DateTime.Now} - Failed to write log of symblinks.{Environment.NewLine}");
                File.AppendAllText(Constants.Errorfile, $"{ex.Message}");
                File.AppendAllText(Constants.Errorfile, $"{ex.StackTrace}");
            }

            LoadService.CreateSymbLink(symblist);
        }