system.UnauthorizedAcceccException in xamarin forms ios

AMNishanthiKumariAMNishanthiKumari USMember ✭✭✭

I am trying to open and edit document in xamarin forms ios. This is my code

             public void Save(string filePath, Stream stream)
                    filePath = filePath.RemoveFilePrefix();

                    var fileDir = Path.GetDirectoryName(filePath);
                    if (!string.IsNullOrEmpty(fileDir))

                    using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))

I am getting this error when execute this code.



  • ObrockiObrocki Member ✭✭

    What about something like this?

  • ObrockiObrocki Member ✭✭
               var folder = await GetFilesFolder();
                var file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
                using(var writer = await file.OpenAsync(FileAccess.ReadAndWrite))
                    await reader.CopyToAsync(writer);
Sign In or Register to comment.