public bool FileExists(string path) { string actualPath = nativeFileSystem.CombinePaths(fs_root, path); if (string.IsNullOrWhiteSpace(path)) { throw new System.ArgumentException("Path cannot be empty", "path"); } if (!nativeFileSystem.IsPathValid(actualPath, true)) { throw new InvalidPathException(actualPath); } try { return(nativeFileSystem.FileExists(actualPath)); } catch (FileSystemException e) { Engine.Log.WriteLine("error/system/filesystem", "Failed to check if file {0} exists ({1})", path, e.Message); return(false); } }
private async void LstAttachments_ItemSelected(object sender, SelectedItemChangedEventArgs e) { try { if (e.SelectedItem == null) { return; } Attachment att = (Attachment)e.SelectedItem; lstAttachments.SelectedItem = null; string attDir = GetAttachmentDir(this.inboxMessage); string file = fileSystem.JoinPaths(attDir, FileHelper.SanitizeFileName(att.NomeArquivo)); att.Loading = true; bool fileExists = fileSystem.FileExists(file); using (var stream = fileSystem.GetFileStream(file)) { if (!fileExists || stream.Length < att.Tamanho) { await HttpRequest.DownloadFileToStream(EndPointHelper.GetAbsoluteUrl(att.Url), stream); stream.Flush(); } } att.Loading = false; ShareViewModel share = new ShareViewModel(); share.FileName = file; share.MimeType = att.MimeType; share.Share(); } catch (Exception ex) { await DisplayAlert(AppResources.APP_TITLE, ex.Message, AppResources.OK); } }