0

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);
Connell.O'Donnell
  • 3,603
  • 11
  • 27
  • 61
misza
  • 1
  • Is the user's name user? – Duston Dec 23 '20 at 20:47
  • Hi, please let me know where i can check it ? I did not change anything so maybe yes, user's name is user. – misza Dec 24 '20 at 09:08
  • It would be the name of the user account you used to log on to the machine. You can also check c:\users to see if there is indeed a ./user subdirectory there. – Duston Dec 28 '20 at 13:43
  • Hi, yes, so user's name is user, what next ? ;) – misza Dec 29 '20 at 14:51
  • I think you'll find that if you try to go to that subdirectory as another user with Explorer (even as Administrator) you'll get a prompt for permissions. I suspect that's what you're seeing. Beyond using another subdirectory, I don't know how (or if) apps handle this situation. – Duston Dec 29 '20 at 15:10
  • Thanks, in my xamarin app i just want to save some data on my PC from c# calculation, do you know how to do this in simply way ? – misza Dec 30 '20 at 08:45
  • I'm not familiar enough with the Xamarin platform and environment to answer. – Duston Dec 30 '20 at 14:22

0 Answers0