I know that there are a lot of questions concerning getting a
"System.UnauthorizedAccessException".
However I couldn't find a solution in any of these questions, as most of the answers refer to one of these Microsoft help pages.
My Situation: I try to save some user input as .csv, so I can import it when needed.
My Code:
var csv = new System.Text.StringBuilder();
            string dir = Path.Combine(Environment.GetFolderPath
            (Environment.SpecialFolder.DesktopDirectory), "test.csv");
            var newLine = string.Format("{0},{1},{2},{3},{4}", txtFirstName.Text, txtLastName.Text, txtEmail.Text,
                txtPhone.Text, txtPlace.Text);
            csv.AppendLine(newLine);
            if (!File.Exists(dir))
            {
                using (FileStream fs = File.Create(dir))
                {
                    Byte[] info = new System.Text.UTF8Encoding(true).GetBytes("FirstName,LastName,Email,Phone,Place");
                    // Add headers to the file.
                    fs.Write(info, 0, info.Length);
                }
            }
            try
            {
                File.AppendAllText(dir, csv.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
As you can see, I'm trying to write everything to my Desktop, in a file called "test.csv". I am running Visual Studio as an Administrator and the file I have on my Desktop is not read-only. Does anybodoy have an idea why this still fails?
Edit: I'm running this as a Standard UWP-App on a desktop Computer.