misza
misza

Reputation: 1

System.UnauthorizedAccessException Message=Access to the path "/C:\Users\user\Desktop\C\dok.txt" is denied

I'm trying to export data to PC local drive from a C# xamarin app. Even as an administrator, I have the same problem as in the title, no matter if the file exist or not... code below, x,y are List :

        var csv = new StringBuilder();

        for (int i = 0; i < x.Count; i++)
        {

            var first = x[i].ToString();
            var second = y[i].ToString();
            var newLine = string.Format("{0}  - {1}", first, second);
            csv.AppendLine(newLine);

        }

        byte[] data = Encoding.ASCII.GetBytes(csv.ToString());
        File.WriteAllBytes(@"C:\Users\user\Desktop\C\" + "dok.txt", data);

Upvotes: 0

Views: 223

Answers (0)

Related Questions