gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
C# 下载文件并创建文件夹
- User
C# 下载文件并创建文件夹
- Assistant
以下是使用C#下载文件并创建文件夹的示例:
using System; using System.IO; using System.Net; namespace DownloadFileAndCreateFolderExample { class Program { static void Main(string[] args) { // URL of the file to download var fileUrl = "https://example.com/file.pdf"; // Path of the folder to create and where to save the downloaded file var folderPath = @"C:\NewFolder"; try { // Create the folder if it doesn't exist if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } // Build the full path of the downloaded file var fileName = Path.GetFileName(fileUrl); var filePath = Path.Combine(folderPath, fileName); // Download the file using (var client = new WebClient()) { client.DownloadFile(fileUrl, filePath); } Console.WriteLine("File downloaded successfully at: " + filePath); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.