ReadAllLines() public static méthode

public static ReadAllLines ( String path ) : String[]
path String
Résultat String[]
Exemple #1
0
        public void RemoveLinesInFile(string filePath, IFileLinePredicate predicate, string destinationPath = null)
        {
            if (destinationPath.IsNull())
            {
                destinationPath = filePath;
            }

            string[] lines      = File.ReadAllLines(filePath);
            int      linesCount = lines.Length;

            List <string> destinationLines = new List <string>();

            for (int r = 0; r < linesCount; r++)
            {
                string oldLine = lines[r];

                if (!predicate.IsTrue(oldLine))
                {
                    destinationLines.Add(oldLine);
                }
            }

            if (predicate.IsSimulation)
            {
                return;
            }

            File.WriteAllLines(destinationPath, destinationLines);
        }
Exemple #2
0
        private static void CorrectingFiles(string path)
        {
            var csFilesPath  = Path.Combine(path, "Files", "cs");
            var resourcePath = Path.Combine(path, "Resources");
            var schemasPath  = Path.Combine(path, "Schemas");
            var names        = new List <string>();
            var csFilesDir   = new DirectoryInfo(csFilesPath);

            foreach (var file in csFilesDir.GetFiles("*.cs"))
            {
                var name = file.Name.Split('.')[0];
                names.Add(name);
                var currentResourcesDirectory = new DirectoryInfo(Path.Combine(resourcePath, name + ".SourceCode"));
                if (!currentResourcesDirectory.Exists)
                {
                    break;
                }
                var countLines = 0;
                foreach (var resourceFile in currentResourcesDirectory.GetFiles("*.xml"))
                {
                    var currentCount = File.ReadAllLines(resourceFile.FullName).Length;
                    countLines = countLines > currentCount ? countLines : currentCount;
                }
                if (countLines < 9)
                {
                    currentResourcesDirectory.Delete(true);
                    Directory.Delete(Path.Combine(schemasPath, name), true);
                }
                else
                {
                    File.WriteAllText(Path.Combine(schemasPath, name, file.Name), string.Empty);
                }
            }
        }
Exemple #3
0
        private static IFilter BuildFilter(CommandLineParser parser)
        {
            var filter = Filter.BuildFilter(parser);

            if (!string.IsNullOrWhiteSpace(parser.FilterFile))
            {
                if (!File.Exists(parser.FilterFile.Trim()))
                {
                    System.Console.WriteLine("FilterFile '{0}' cannot be found - have you specified your arguments correctly?", parser.FilterFile);
                }
                else
                {
                    var filters = File.ReadAllLines(parser.FilterFile);
                    filters.ToList().ForEach(filter.AddFilter);
                }
            }
            else
            {
                if (parser.Filters.Count == 0)
                {
                    filter.AddFilter("+[*]*");
                }
            }

            return(filter);
        }
Exemple #4
0
 public static void Edit(string path)
 {
     //Ontology.EraseConcepts();
     //Parser.LoadDefinitions(path);
     Declarations.Clear();
     Declarations.AddRange(File.ReadAllLines(path));
 }
Exemple #5
0
        public static InflectionProcess[] FromFile(string path)
        {
            var lines   = File.ReadAllLines(path).Where(line => !line.StartsWith("#"));
            var columns = lines.Select(line => line.Split('\t'));

            return(columns.Select(line => new InflectionProcess(line[0], line[1])).ToArray());
        }
        /// <summary>
        /// Сортировка файла.
        /// </summary>
        /// <returns>Отсортированный файл.</returns>
        public string[] sort()
        {
            stream.Close();                                //закрываем поток
            if (SFile.Exists(fname) & fname.Length <= 260) //проверка на существование файла и корректность имени
            {
                try
                {
                    string[] str = SFile.ReadAllLines(fname); //считываем строки
                    Array.Sort(str);                          //сортируем
                    return(str);
                }



                catch (Exception e)                                  //обработка исключений для сортирвки
                {
                    LogForOperations("Сортировка файла", e.Message); //запись в лог ошибки (если есть)
                    throw e;
                }
            }
            else
            {
                LogForOperations("Сортировка файла", "файл не существует либо содержит в своем имени более 260 символов");//запись ошибки в лог, если не выполняется условие проверки
                return(null);
            }
        }
Exemple #7
0
        private void FillTypeSerrBox()
        {
            string[] lines = File.ReadAllLines(@"\\Serv-kalysse\EDatas\Dev\Datas\Casiers\serrures_config.txt");

            if (lines.Length > 2)
            {
                TypeSerrBox.Items.Clear();
                for (int i = 2; i < lines.Length; i++)
                {
                    string[] line = lines[i].Split(';');

                    if (line.Length != 3)
                    {
                        continue;
                    }
                    string name = line[0];
                    TypeSerrBox.Items.Add(name);

                    LockInfos infos = new LockInfos
                    {
                        Name  = name,
                        Code1 = line[1],
                        Code2 = line[2]
                    };
                    Locks.Add(infos);
                }
                TypeSerrBox.SelectedIndex = 0;
            }
        }
        public bool removeLyrics(string title)
        {
            try
            {
                title = title.ToLower().Trim();

                checkLocalResources();
                string[]      lyricsList     = File.ReadAllLines(localResourcesData);
                List <string> lyricsListTemp = new List <string>();
                foreach (string ly in lyricsList)
                {
                    if (ly.Contains("="))
                    {
                        string t = ly.Substring(0, ly.IndexOf("=")).ToLower().Trim();

                        if (t != title)
                        {
                            lyricsListTemp.Add(ly);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                File.Delete(localResourcesData);
                File.WriteAllLines(localResourcesData, lyricsListTemp);

                return(true);
            }
            catch (Exception ex) { }
            return(false);
        }
        public List <string> getLyrics(string title)
        {
            try
            {
                title = title.ToLower().Trim();

                string[] lyricsList = File.ReadAllLines(localResourcesData);

                foreach (string ly in lyricsList)
                {
                    if (ly.Contains("="))
                    {
                        string t = ly.Substring(0, ly.IndexOf("=")).ToLower().Trim();


                        if (t == title)
                        {
                            string        vals    = ly.Substring(ly.IndexOf("=") + 1);
                            List <string> valsArr = vals.Split(',').ToList <string>();
                            // 0 = id, 1 = coverImg, 2 = url
                            return(valsArr);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception ex) { }
            return(new List <String>());
        }
Exemple #10
0
        public static Playlist LoadPlaylist(string file, int index, BackgroundWorker worker = null)
        {
            bool reportProgress = (worker != null);
            int  count          = 0;

            Playlist p = new Playlist();

            p.Name = Path.GetFileNameWithoutExtension(file);

            var lines = File.ReadAllLines(file);

            List <string> invalidFiles = new List <string>();

            List <Song> songs = new List <Song>();

            for (int i = 0; i < lines.Length; i++)
            {
                count++;
                var s = lines[i];
                try
                {
                    if (reportProgress && count > 10)
                    {
                        worker.ReportProgress(1,
                                              new PlaylistWorkerState()
                        {
                            CurrentSong    = i,
                            PlaylistName   = p.Name,
                            PlaylistNumber = index,
                            TotalSongs     = lines.Length
                        });
                        count = 0;
                    }
                    if (File.Exists(s))
                    {
                        var song = new Song(s);
                        p.Size += (song.Size / 1024);
                        songs.Add(song);
                    }
                }
                catch (TagLib.CorruptFileException corrupt)
                {
                    Log.SaveLogFile(MethodBase.GetCurrentMethod(), corrupt);
                }
                catch (TagLib.UnsupportedFormatException unsupported)
                {
                    Log.SaveLogFile(MethodBase.GetCurrentMethod(), unsupported);
                }
            }

            p.Songs        = songs;
            p.Count        = songs.Count;
            p.Sync         = true;
            p.InvalidFiles = invalidFiles;

            return(p);
        }
Exemple #11
0
    static Inflection()
    {
        Inflections = InflectionProcess.FromFile(ConfigurationFiles.PathTo("Inflections", "Regular nouns"));

        foreach (var entry in File.ReadAllLines(ConfigurationFiles.PathTo("Inflections", "Irregular nouns")))
        {
            var split    = entry.Split('\t');
            var singular = split[0];
            var plural   = split[1];
            IrregularPlurals[singular] = plural;
            IrregularSingulars[plural] = singular;
        }
    }
Exemple #12
0
        public static void Init()
        {
            apiKey = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "apiKey"));
            var euristics = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Euristics.txt"));

            foreach (var euristic in euristics)
            {
                EuristicGetter.Euristics.Add(euristic);
            }
            var bot = BotGetter.GetBot(apiKey);

            bot.StartReceiving();
        }
Exemple #13
0
        public static void InvokeConfig(string filePath)
        {
            Debug.Log($"Executing config, {(File.Exists(filePath) ? "<color=green><b>Found</b></color>" : "<color=red><b>Not found</b></color>")} at: {filePath}");
            var lines = File.ReadAllLines(filePath);

            // Parse to remove comments
            for (var i = 0; i < lines.Length; i++)
            {
                var match = commentRegex.Match(lines[i]);
                lines[i] = lines[i].Remove(match.Index, match.Length);
            }

            InvokeCommands(lines);
        }
Exemple #14
0
        private static void LoadSettings()
        {
            try
            {
                string[] lines = File.ReadAllLines("../../../DiscordPresenceConfig.ini");
                foreach (string line in lines)
                {
                    if (ValidPlayers.Contains(line.Split('=')[0].Trim().ToLower()))
                    {
                        EnabledClients[line.Split('=')[0]] = line.Split('=')[1].Trim().ToLower() == "true";
                        if (line.Split('=').Length > 2)
                        {
                            DefaultClients[line.Split('=')[0]] =
                                new DiscordRpcClient(line.Split('=')[2], autoEvents: false);
                        }
                    }
                    else if (InverseWhatpeoplecallthisplayer.ContainsKey(line.Split('=')[0].Trim().ToLower()) &&
                             ValidPlayers.Contains(InverseWhatpeoplecallthisplayer[line.Split('=')[0].Trim().ToLower()])
                             )
                    {
                        EnabledClients.Add(line.Split('=')[0], line.Split('=')[1].Trim().ToLower() == "true");
                        if (line.Split('=').Length > 2)
                        {
                            Console.WriteLine(InverseWhatpeoplecallthisplayer[line.Split('=')[0]]);
                            DefaultClients[InverseWhatpeoplecallthisplayer[line.Split('=')[0]]] =
                                new DiscordRpcClient(line.Split('=')[2], autoEvents: false);
                        }
                    }
                    else if (line.Split('=')[0].Trim().ToLower() == "verbose" && line.Split('=').Length > 1)
                    {
                        ScreamAtUser = line.Split('=')[1].Trim().ToLower() == "true";
                    }
                }
            }
            catch (Exception)
            {
                Console.Error.WriteLine(
                    "DiscordPresenceConfig.ini not found! this is the settings file to enable or disable certain features");
                Thread.Sleep(5000);
            }

            try
            {
                ReadKeyingFromFile(new DirectoryInfo("../../../clientdata"));
            }
            catch (Exception)
            {
                Console.WriteLine("Something bad happened");
            }
        }
Exemple #15
0
    /// <summary>
    ///     Reads the entire contents of a file and splits them by end-of-line markers.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="encoding">The encoding to use.</param>
    /// <returns>
    ///     An array of <see cref="string" />.
    /// </returns>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" /> in Visual Basic).
    /// </exception>
    /// <remarks>
    ///     This operation always requires an encoding to be used. If <paramref name="encoding" /> is set to
    ///     <see langword="null" />, an implementation-specific
    ///     encoding will be used.
    /// </remarks>
    public string[] ReadAllLines(
        string path,
        Encoding?encoding = null)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(encoding == null
            ? FSFile.ReadAllLines(path)
            : FSFile.ReadAllLines(
                   path,
                   encoding));
    }
Exemple #16
0
        public static void ReadConfigFile(string filePath)
        {
            var lines = File.ReadAllLines(filePath);

            // Add colours to comments
            for (var i = 0; i < lines.Length; i++)
            {
                var match = commentRegex.Match(lines[i]);
                var start = "<color=green>";
                var end   = "</color>";
                lines[i] = $"[{i}] {lines[i].Insert(match.Index, start).Insert(match.Index + match.Length + start.Length, end)}";
            }

            Debug.Log(string.Join("\n", Enumerable.Prepend(lines, $"Reading {lines.Length} lines from {filePath}")));
        }
Exemple #17
0
        private static RiderInfo[] CollectAllRiderPathsLinux()
        {
            var    installInfos = new List <RiderInfo>();
            string home         = Environment.GetEnvironmentVariable("HOME");

            if (!string.IsNullOrEmpty(home))
            {
                string toolboxRiderRootPath = GetToolboxBaseDir();
                installInfos.AddRange(CollectPathsFromToolbox(toolboxRiderRootPath, "bin", "rider.sh", false)
                                      .Select(a => new RiderInfo(a, true)).ToList());

                //$Home/.local/share/applications/jetbrains-rider.desktop
                var shortcut = new FileInfo(Path.Combine(home, @".local/share/applications/jetbrains-rider.desktop"));

                if (shortcut.Exists)
                {
                    string[] lines = File.ReadAllLines(shortcut.FullName);
                    foreach (string line in lines)
                    {
                        if (!line.StartsWith("Exec=\""))
                        {
                            continue;
                        }
                        string path = line.Split('"').Where((item, index) => index == 1).SingleOrDefault();
                        if (string.IsNullOrEmpty(path))
                        {
                            continue;
                        }

                        if (installInfos.Any(a => a.Path == path)) // avoid adding similar build as from toolbox
                        {
                            continue;
                        }
                        installInfos.Add(new RiderInfo(path, false));
                    }
                }
            }

            // snap install
            string snapInstallPath = "/snap/rider/current/bin/rider.sh";

            if (new FileInfo(snapInstallPath).Exists)
            {
                installInfos.Add(new RiderInfo(snapInstallPath, false));
            }

            return(installInfos.ToArray());
        }
Exemple #18
0
        public IActionResult RunAll(string constellation, string include, string exclude)
        {
            HashSet <string> includeSet = null, excludeSet = null, excludeSuites = null;
            int partIndex = 0;
            int partCount = 1;

            if (!String.IsNullOrEmpty(include))
            {
                includeSet = new HashSet <string>(include.Split(','));
            }
            if (!String.IsNullOrEmpty(exclude))
            {
                excludeSet = new HashSet <string>(exclude.Split(','));
            }
            if (!String.IsNullOrEmpty(constellation) && constellation.Contains('(') && constellation.EndsWith(')'))
            {
                var constellationParts = constellation.TrimEnd(')').Split('(');
                var parts = constellationParts[1].Split('/');

                constellation = constellationParts[0];
                partIndex     = Int32.Parse(parts[0]) - 1;
                partCount     = Int32.Parse(parts[1]);
            }

            var packageJson = IOFile.ReadAllText(Path.Combine(_env.ContentRootPath, "package.json"));

            if (_runFlags.IsContinuousIntegration)
            {
                if (IOFile.Exists(_completedSuitesFileName))
                {
                    var completedSuites = IOFile.ReadAllLines(_completedSuitesFileName);
                    excludeSuites = new HashSet <string>(completedSuites);
                }
            }

            var model = new RunAllViewModel
            {
                Constellation  = constellation ?? "",
                CategoriesList = include,
                Version        = JsonConvert.DeserializeObject <IDictionary>(packageJson)["version"].ToString(),
                Suites         = UIModelHelper.GetAllSuites(HasDeviceModeFlag(), constellation, includeSet, excludeSet, excludeSuites, partIndex, partCount)
            };

            AssignBaseRunProps(model);

            return(View(model));
        }
Exemple #19
0
        public static void Seed()
        {
            GrowlHelper.SimpleGrowl("Seeding Colors");
            var repo = new ColorRepository();

            repo.DeleteAll();


            var lines = File.ReadAllLines(Path.Combine(AppPaths.Instance.GetMigrationDataFolder(), "dbo_Colors.csv")).Select(a => a.Split(';'));

            foreach (var x in lines)
            {
                var c = new Color();
                c.Name = x.First().Split(',')[0].Trimmed();

                repo.Insert(c);
            }
        }
Exemple #20
0
        //===============
        // Storage
        //===============
        public static void Load()
        {
            Time.Start();
            var cachePath = Proxy.IsEditor() ? "Temp/File.data" : File.root + "/File.data";

            if (File.Exists(cachePath))
            {
                string extension = "";
                string lastPath  = "";
                var    lines     = SystemFile.ReadAllLines(cachePath);
                for (int index = 0; index < lines.Length; ++index)
                {
                    var line = lines[index];
                    if (line.StartsWith("("))
                    {
                        extension = line.Parse("(", ")");
                    }
                    else if (line.StartsWith("=") || line.StartsWith("+"))
                    {
                        lastPath = line.StartsWith("=") ? line.TrimLeft("=").Replace("$", File.root) : lastPath + line.TrimLeft("+");
                        var folderData = new FileData();
                        folderData.name      = lastPath.GetPathTerm();
                        folderData.directory = lastPath.GetDirectory();
                        folderData.path      = lastPath;
                        folderData.isFolder  = true;
                        File.BuildCache(folderData);
                    }
                    else
                    {
                        var fileData = new FileData();
                        fileData.directory = lastPath;
                        fileData.name      = line;
                        fileData.fullName  = fileData.name + "." + extension;
                        fileData.path      = fileData.directory + "/" + fileData.fullName;
                        fileData.extension = extension;
                        File.BuildCache(fileData);
                    }
                }
            }
            if (File.clock)
            {
                Log.Show("[File] : Load cache complete -- " + Time.Passed() + ".");
            }
        }
Exemple #21
0
        private static void Pack(PackOptions options)
        {
            var writer = new ArchiveWriter();

            string[] fileOrder = File.ReadAllLines(Path.Combine(options.Source, FileOrderFileName));

            foreach (var file in fileOrder)
            {
                var filePath = Path.Combine(options.Source, file);
                var fileName = Path.GetFileName(filePath).UnicodeUnReplaceSlash();
                var fileData = File.ReadAllBytes(filePath);
                writer.AddFile(fileName, fileData);
            }

            // Write file to new location.
            Directory.CreateDirectory(Path.GetDirectoryName(options.SavePath));
            using var fileStream = new FileStream(options.SavePath, FileMode.Create, FileAccess.Write, FileShare.None);
            writer.Write(fileStream, options.BigEndian);
        }
Exemple #22
0
        private static void PackAll(PackAllOptions packAllOptions)
        {
            var sources = File.ReadAllLines(packAllOptions.Sources);
            var paths   = File.ReadAllLines(packAllOptions.SavePaths);

            if (sources.Length != paths.Length)
            {
                throw new ArgumentException("Amount of source folders does not equal amount of save paths.");
            }

            for (int x = 0; x < sources.Length; x++)
            {
                Console.WriteLine($"Saving: {paths[x]}");
                Pack(new PackOptions()
                {
                    SavePath = paths[x], Source = sources[x], BigEndian = packAllOptions.BigEndian
                });
            }
        }
Exemple #23
0
        public void ReplaceTextInFile(string filePath, IStringReplace stringConverter)
        {
            string[] lines      = File.ReadAllLines(filePath);
            int      linesCount = lines.Length;

            string[] newLines = new string[linesCount];
            for (int r = 0; r < linesCount; r++)
            {
                string oldLine = lines[r];
                string newLine = stringConverter.GetNewString(oldLine);
                newLines[r] = newLine;
            }

            if (stringConverter.IsSimulation)
            {
                return;
            }

            File.WriteAllLines(filePath, newLines);
        }
Exemple #24
0
    /// <summary>
    ///     Asynchronously reads the entire contents of a file and splits them by end-of-line markers.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="encoding">The encoding to use.</param>
    /// <param name="cancellationToken">The cancellation token to stop this operation.</param>
    /// <returns>
    ///     An array of <see cref="string" />.
    /// </returns>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" /> in Visual Basic).
    /// </exception>
    /// <remarks>
    ///     This operation always requires an encoding to be used. If <paramref name="encoding" /> is set to
    ///     <see langword="null" />, an implementation-specific
    ///     encoding will be used.
    /// </remarks>
    public Task <string[]> ReadAllLinesAsync(
        string path,
        Encoding?encoding = null,
        CancellationToken cancellationToken = default)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(encoding == null
            ? Work.OnThreadPoolAsync(
                   FSFile.ReadAllLines,
                   path,
                   cancellationToken)
            : Work.OnThreadPoolAsync(
                   state => FSFile.ReadAllLines(
                       state.Path,
                       state.Encoding),
                   (Path: path, Encoding: encoding),
                   cancellationToken));
    }
        public static bool LocalHostExists(string hostName, string ipAddress)
        {
            var lines = File.ReadAllLines(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "drivers/etc/hosts"));

            if (lines == null || lines.Length < 1)
            {
                return(false);
            }
            for (var i = 0; i < lines.Length; i++)
            {
                if (string.IsNullOrWhiteSpace(lines[i]))
                {
                    continue;
                }
                lines[i] = lines[i].Trim();
                if (lines[i].StartsWith(ipAddress) && lines[i].EndsWithI(hostName))
                {
                    return(true);
                }
            }
            return(false);
        }
        public void ReadFile(string fileName)
        {
            string[] exportFileData;

            //TODO: Need to refactoring later
            //Pause before start reading
            Thread.Sleep(1000);

            while (true)
            {
                try
                {
                    exportFileData = File.ReadAllLines(fileName);
                    break;
                }
                catch (IOException)
                {
                    Thread.Sleep(300);
                }
            }

            ProcessDataFile(fileName, exportFileData);
        }
Exemple #27
0
        /// <summary>
        /// Сортировка содержимого.
        /// </summary>
        /// <param name="strReverse">Обратная сортировка.</param>
        /// <returns>Отсортированный массив.</returns>
        public string[] sort(bool strReverse)
        {
            stream.Close();//закрываем поток
            try
            {
                if (fname.Length != 0 & SFile.Exists(fname))  //проверка на существование файла и корректности имени
                {
                    string[] str = SFile.ReadAllLines(fname); //считываем строки
                    if (str.Length != 0)                      //проверка на существование аргумента
                    {
                        Array.Sort(str);                      //сортируем
                        if (strReverse)                       //обратная сортировка при значении true
                        {
                            Array.Reverse(str);
                        }
                    }
                    else
                    {
                        LogForOperations("Сортировка файла", "файл пуст");
                    }
                    return(str);
                }
                else
                {
                    LogForOperations("Сортировка файла", "не указано имя файла либо файл не существует");//запись ошибки в лог, если не выполняется условие проверки

                    return(null);
                }
            }


            catch (Exception e)                                  //обработка исключений для сортирвки
            {
                LogForOperations("Сортировка файла", e.Message); //запись в лог ошибки (если есть)
                throw e;
            }
        }
Exemple #28
0
        public void found1(int datag)
        {
            string[] disks = Directory.GetLogicalDrives();
            Directory.CreateDirectory("config\\data\\" + datag + "\\");

            ZipFile.ExtractToDirectory(data2, "config\\data\\" + datag + "\\");

            data3             = File.ReadAllLines("config\\data\\" + datag + "\\install.Fcl", Encoding.Default);
            label1.Text       = data3[0];
            label2.Text       = data3[1];
            this.Text         = data3[2];
            richTextBox1.Text = data3[3];
            sc  = data3[4];
            sc1 = data3[5];

            for (int ii = 0; ii < disks.Length; ii++)
            {
                //循环添加到列表中
                comboBox1.Items.Add(disks[ii]);
                //设置属性默认选择第1个
                comboBox1.SelectedIndex = 0;
            }
            abc1 = false;
        }
Exemple #29
0
        // Package Info Location Data Ex: chrome;86;https://example.com/chromedownload.json
        public static void InstallPackage(string query)
        {
            WebClient client = new WebClient();

            Screen.PrintLn(":: Updating Repositories");
            MirrorManager.DownloadMirrors();

            string packageInstallJson = "";

            foreach (string mirror in Directory.GetFiles(Config.MirrorFolderLocation))
            {
                string[] fileContent = File.ReadAllLines(mirror);

                foreach (string line in fileContent)
                {
                    string[] lineSplit = line.Split(';');

                    if (line.StartsWith(query))
                    {
                        Screen.Print($":: Package {lineSplit[0]} version {lineSplit[1]} (y/n)? ");
                        ConsoleKeyInfo keypress = Console.ReadKey();

                        if (keypress.KeyChar is 'y' or 'Y')
                        {
                            packageInstallJson = client.DownloadString(lineSplit[2]);
                        }
                        else
                        {
                            client.Dispose();
                            Screen.PrintLn("Ok cancelled.");

                            Environment.Exit(0);
                        }
                    }
                }
            }
Exemple #30
0
 public string[] ReadAllLines()
 => F.ReadAllLines(this.FullName);