Skip to content

Class Network

Kristian Virtanen edited this page Oct 14, 2024 · 3 revisions

Description:

Provides methods to perform network operations, such as downloading files and retrieving web page contents.

Example codes:

Methods:

  • Network.DownloadFile(fileName, url)
  • Downloads a file from the specified URL and saves it to the provided file path.
  • Returns the path to the saved file, or an empty string if the download fails

  • Network.GetWebPageContents(url)
  • Retrieves the contents of a web page as a string.
  • Returns the contents of the web page as a string, or an empty string if the request fails.

Top

Example code in SmallBasicOE:

Console.WriteLine(Network.GetWebPageContents("http://example.com"))
Network.DownloadFile("temp.svg", "https://huggingface.co/front/assets/huggingface_logo-noborder.svg")

Top

Example code in C#:

namespace SmallBasicOpenEditionDll
{
    class Program2
    {
        static void Main(string[] args)
        {
            string content = Network.GetWebPageContents("http://example.com");
            Console.WriteLine(content);

            string fileName = "temp.txt";
            Network.DownloadFile(fileName, "https://huggingface.co/front/assets/huggingface_logo-noborder.svg");
        }
    }
}

Top

Clone this wiki locally