private void AddFileSystem(string absolutePath) { long freeBytes = FileSystemHelper.GetAvailableFileSystemSizeInBytes(absolutePath); long totalBytes = FileSystemHelper.GetTotalFileSystemSizeInBytes(absolutePath); long usedBytes = totalBytes - freeBytes; string[] freeSize = DisplayFormatter.RenderFileSize(freeBytes).Split(' '); string[] totalSize = DisplayFormatter.RenderFileSize(totalBytes).Split(' '); var view = DriveVolumeInfoViewFactory.GetNewView(ApplicationContext); view.Title = ConvertPathToTitle(absolutePath); view.SetSpace( Convert.ToInt32(ByteConverter.BytesToMegabytes(usedBytes)), Convert.ToInt32(ByteConverter.BytesToMegabytes(totalBytes)), freeSize[0], freeSize[1], totalSize[0], totalSize[1]); Observables?.AddInfoView?.Invoke(this, view.GetView()); }
private ReadOnlyControlFile OpenControlFile(Android.Net.Uri uri) { try { ContentResolver resolver = Application.ContentResolver; var stream = resolver.OpenInputStream(uri); var xml = new XmlDocument(); xml.Load(stream); var control = new ReadOnlyControlFile(xml); var podcasts = control.GetPodcasts(); int count = 0; foreach (var item in podcasts) { count++; } NoOfFeeds = count; AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {control.GetSourceRoot()}"); AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {count}"); SetTextViewText(Resource.Id.txtConfigFilePath, $"{uri.ToString()}"); freeBytesNet = GetFreeBytes(control.GetSourceRoot()); freeBytesAndroid = FileSystemHelper.GetAvailableFileSystemSizeInBytes(control.GetSourceRoot()); totalBytesAndroid = FileSystemHelper.GetTotalFileSystemSizeInBytes(control.GetSourceRoot()); var output = $"{count}, {control.GetSourceRoot()}\nFree space (Net): {DisplayFormatter.RenderFileSize(freeBytesNet)}\nFree/total space (Android): {DisplayFormatter.RenderFileSize(freeBytesAndroid)}/{DisplayFormatter.RenderFileSize(totalBytesAndroid)}"; SetTextViewText(Resource.Id.txtOutput, output); return(control); } catch (Exception ex) { AndroidApplication.Logger.LogException(() => $"MainActivity: OpenConfigFile", ex); SetTextViewText(Resource.Id.txtConfigFilePath, $"Error {ex.Message}"); return(null); } }