Advertisement
TERIHAX

Modified Version of Alex's Lib

Oct 17th, 2021
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Function_Library
  11. {
  12.     class Functions
  13.     {
  14.         //Made by AlexDev. (ad_ofc#7068).
  15.         // Modified by TERI (Tires#3415)
  16.  
  17.         string LoadUrl(string url) //Gets text from a raw website and returns. (Alex)
  18.         {
  19.             // Alex
  20.             /*
  21.             WebClient wc = new WebClient();
  22.             string clipped = wc.DownloadString(url);
  23.             return clipped;
  24.             */
  25.  
  26.             // TERI
  27.             // (TERI) 'Using' statement auto disposes, glad I learned that from Vortex/Baba Yaga lmfao like over 4 months ago or something I don't remember, oh god this sentence is starting to be long damn holy hell damn wow you're still reading and wasting your time over this sentence wow I took a year to write this sentence and yet you're wasting your time reading it, and you're still here fam just continue down no point of reading this, don't move the scrollbar right, there's totally nothing there totally not capping                                                                                          ;-; ur mom fat bc ur still here reading it
  28.             using (var wc = new WebClient { Proxy = null }) // Proxy to null makes it a bit harder to grab the url and stuff Ig
  29.             {
  30.                 return wc.DownloadString(url);
  31.             }
  32.         }
  33.  
  34.         // (TERI) Ok this function/method name is confusing af, it sounds like you're downloading a url as a file
  35.         // (TERI) This should be named "DownloadFile" or something
  36.         void DownloadUrl(string url, string name) //Downloads a file from the given url. (Alex)
  37.         {
  38.             // Alex
  39.             /*
  40.             WebClient wc = new WebClient();
  41.             wc.DownloadFile(url, name);
  42.             */
  43.  
  44.             // TERI
  45.             using (var wc = new WebClient { Proxy = null })
  46.             {
  47.                 wc.DownloadFile(new Uri(url).ToString(), name); // (TERI) ToString() makes it to like a correct url, so like if someone puts "google.com/favicon.ico" it's gonna turn to "http://google.com/favicon.ico"
  48.             }
  49.         }
  50.  
  51.         // (TERI) No need but alr Ig
  52.         void MakeFolder(string filename) //Makes a folder in the base directory (Alex)
  53.         {
  54.             Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/" + filename);
  55.         }
  56.  
  57.         string ReadFile(string filename) //Reads a .txt from the current directory (Alex)
  58.         {
  59.             // Alex
  60.             /*
  61.             string readfile_file = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + filename);
  62.             return readfile_file;
  63.             */
  64.  
  65.             // TERI
  66.             return File.ReadAllText(Environment.CurrentDirectory + "\\" + filename);
  67.         }
  68.  
  69.         void WriteFile(string iname, string text) //Writes a txt that exists in the directory (Alex)
  70.         {
  71.             File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + iname, text);
  72.         }
  73.  
  74.         void MakeFile(string iname, string text) //Makes a new file and writes in it, if it exists, its writes it. (Alex)
  75.         {
  76.             File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + iname, text);
  77.         }
  78.  
  79.         void StartProgram(string name)//Starts a program. (Alex)
  80.         {
  81.             Process.Start(AppDomain.CurrentDomain.BaseDirectory + name);
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement