Exemple #1
0
        public void DeleteSymbol()
        {
            Console.WriteLine($"Введите символ\\слово:");
            var symbol = Console.ReadLine();

            if (string.IsNullOrEmpty(symbol))
            {
                return;
            }

            if (FileData.Contains(symbol))
            {
                string ext = Path.GetExtension(_filePath);;
                string textFileNameCopy = Path.GetFileNameWithoutExtension(_filePath) + "_copy" + ext;
                File.Copy(_filePath, textFileNameCopy, true);
                var fileDataWithDeletedSymbol = FileData.Replace(symbol, "", true, CultureInfo.CurrentCulture);
                File.WriteAllText(_filePath, fileDataWithDeletedSymbol);
                Console.WriteLine(fileDataWithDeletedSymbol);
            }
            else
            {
                Console.WriteLine($"Ошибка - в тексте нет указаного символа\\слова {symbol}");
            }
        }
        private void StartSave(ClothingType type)
        {
            string DirType = type.ToString().Replace("Classic", "");

            LogData(LogType.Info, $"Initiating first download step...");
            new Thread(() =>
            {
                foreach (string ID in ItemIDs)
                {
                    using (WebClient client = new WebClient())
                    {
                        if (type == ClothingType.Accessories)
                        {
                            client.DownloadFileCompleted += (s, e) =>
                            {
                                LogData(LogType.Info, $"Downloaded: https://www.roblox.com/catalog/{ID}");
                            };
                            client.DownloadFileAsync(new Uri($"https://assetdelivery.roblox.com/v1/asset?id={ID}"), $"{SaveDirectory}\\Accessories\\{ID}.rbxm");
                        }
                        else
                        {
                            try
                            {
                                client.DownloadFileAsync(new Uri($"https://assetdelivery.roblox.com/v1/asset?id={ID}"), $"{SaveDirectory}\\temp\\{ID}");
                                client.DownloadFileCompleted += (erere, ererer) =>
                                {
                                    string FileData;
                                    try
                                    {
                                        FileData = File.ReadAllText($"{SaveDirectory}\\temp\\{ID}");
                                    }
                                    catch (Exception er) { FileData = ""; Console.WriteLine(er.ToString()); }

                                    if (FileData.Contains("roblox"))
                                    {
                                        try
                                        {
                                            File.Delete($"{SaveDirectory}\\temp\\{ID}");
                                        }
                                        catch (Exception er) { Console.WriteLine(er.ToString()); }
                                    }
                                    else
                                    {
                                        try
                                        {
                                            File.Move($"{SaveDirectory}\\temp\\{ID}", $"{SaveDirectory}\\Shirts\\{GetValidName(GetAssetName(ID))}.png");
                                        }
                                        catch (Exception er) { Console.WriteLine(er.ToString()); }
                                        return;
                                    }

                                    Console.WriteLine(ParseFile(FileData));
                                    try
                                    {
                                        client.DownloadFile(ParseFile(FileData), $"{SaveDirectory}\\Shirts\\{GetValidName(GetAssetName(ID))}.png");
                                    }
                                    catch (Exception er) { Console.WriteLine(er.ToString()); }
                                    FinishedItems++;
                                    Console.WriteLine("Finished a download!");
                                };
                            }
                            catch { }
                        }
                    }
                }
            }).Start();
        }