System Unauthorized

Hello, I have run into some problems in mono. I try and debug the program, and no matter what, it comes up with the same error; Error Error: System.UnauthorizedAccessException: Access to the path ‘C:\Users\Craig’ is denied. (Error: System.UnauthorizedAccessException) (Assembly-UnityScript-firstpass). The interesting thing is, that folder “Craig” wasn’t even created! It looks for the folder, but its not there! I created one to try and circumvent it, but it just said it didn’t have access to it. I’m not sure why its doing this. Any help would be appreciated.

Thanks!
Craig

Here’s a fairly simple script I wrote for you to try out. I have tested and it works. This is a C# script. Let me know if you have any issues and I will resolve them for you. Copy the code below and paste into a new C-Sharp Script named FileTest. Be sure to use : using System.IO when dealing w/ Directory and File objects. This script will check for the directory and file. If something doesn’t exist, this script will create it. If the file doesn’t exist, the GUI Button will read “Create File”. Once you click on the button, it will create the directory and file, then it will read “Write to file”. Once you click on the button again, it will write a string to the txt file and open the file with the new appended text.

using System.IO;
using System.Collections;
using UnityEngine;

public class FileTest : MonoBehaviour
{
	string ButtonText;
	
	void Update()
	{
		if(!File.Exists("C:/Users/Craig/Test.txt"))
			ButtonText = "Create File";
		else if(File.Exists("C:/Users/Craig/Test.txt"))
			ButtonText = "Write To File";
	}
	
	void OnGUI()
	{
		if(GUI.Button (new Rect(200, 200, 128, 30), ButtonText))
		{
			if(!Directory.Exists("C:/Users/Craig"))
			{
				Directory.CreateDirectory("C:/Users/Craig");
				File.Create("C:/Users/Craig/Test.txt");
			}
			else if(Directory.Exists("C:/Users/Craig") && !File.Exists("C:/Users/Craig/Test.txt"))
				File.Create("C:/Users/Craig/Test.txt");
			else if(Directory.Exists("C:/Users/Craig") && File.Exists("C:/Users/Craig/Test.txt"))
			{
				File.WriteAllText("C:/Users/Craig/Test.txt", "Damn, Bro, you just created a file and wrote this text to it :D");
				System.Diagnostics.Process.Start ("C:/Users/Craig/Test.txt");
			}
		}
	}
}