Пример #1
0
        private void RemoveStream(Android.Net.Uri docUri)
        {
            //some storage (maybe older android) does not free space till truncate the file. it is a temporaray solution
            //var stream = OpenStream(docUri, StreamMode.Truncate, StreamAccess.Write, StreamShare.None);
            //stream.Dispose();

            if (!DocumentsContract.DeleteDocument(Context.ContentResolver, docUri))
            {
                throw new Exception($"Could not delete stream. Uri: {docUri}");
            }
        }
Пример #2
0
        public void RemoveStorage(Android.Net.Uri docUri)
        {
            //some OTG flags does not release cause lost directory so remove directory recursively
            var subStorages = GetEntries().Where(x => x.IsStorage).Select(x => (SafStorgeProvider)OpenStorage(docUri));

            foreach (var subStorage in subStorages)
            {
                subStorage.EraseStorage();
                subStorage.Dispose();
            }

            if (!DocumentsContract.DeleteDocument(Context.ContentResolver, docUri))
            {
                throw new Exception($"Could not delete storage. Uri: {docUri}");
            }
        }