Gain access to directory

Hey guys, I am trying to write a code that downloads “extra” content to the users computer after the application has been downloaded (to reduce download time and save space). So far I have only researched it, and attempted to try with a copy-and-pasted bit of code. I am getting an “UnauthorizedAccessException”, so I asume that I can’t download a file from the internet without the users permission; and thats why I am writing this question.

My code (mainly from Download Files from Web [C#]) as well as the error I am currently getting are at the bottom, respectively.

using System;
using System.IO;
using System.Net;
using UnityEngine;
using System.Security.AccessControl;
//Written by Gibson Bethke
public class Download : MonoBehaviour {
	static public string newFile = "/Users/" + Environment.UserName + "/Desktop/Downloads";

	void Start () {
		if (Directory.Exists(newFile)) {
		} else {
			Directory.CreateDirectory (newFile);
	void OnGUI () {
		if (GUI.Button(new Rect(1300,875,100,50), "Download")) {
			WebClient webClient = new WebClient();
			webClient.DownloadFile("", newFile);

UnauthorizedAccessException: Access to the path '/Users/************/Desktop/Downloads' is denied.
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options)
System.IO.FileStream..ctor (System.String path, FileMode mode)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode)
System.Net.WebClient.DownloadFileCore (System.Uri address, System.String fileName, System.Object userToken)
System.Net.WebClient.DownloadFile (System.Uri address, System.String fileName)
Rethrow as WebException: An error occurred performing a WebClient request.
System.Net.WebClient.DownloadFile (System.Uri address, System.String fileName)
System.Net.WebClient.DownloadFile (System.String address, System.String fileName)
(wrapper remoting-invoke-with-check) System.Net.WebClient:DownloadFile (string,string)
Download.OnGUI () (at Assets/Download From Web/Download.cs:22)

So, if anyone has any advice, I will really appreciate if you share it with us/me.

Thanks for all your help!

P.S. I am aware that the file I am currently trying to download is not “extra” content, but a hand-drawn image of a pony.
P.P.S. I am not trying to do this in/with a web player; I am trying it in the engine itself, and I intend to use it in a standalone.

I suspect you are running into basic unity player permission issues. You can’t download to a user dir through a web build of the game. Which is what I assuming you’re trying to do here. You can download a package and use it directly but there’s no way to save it locally via webbuild/deployed builds.