Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using Xamarin.Forms;
- namespace TreningsApplikasjon.iOS
- {
- public class FileAccess : IFileAccess
- {
- public FileAccess ()
- {
- }
- public bool Exists (string filename)
- {
- var filePath = GetFilePath (filename);
- if (File.Exists (filePath)) {
- FileInfo finf = new FileInfo (filePath);
- return finf.Length > 0;
- } else
- return false;
- }
- public string FullPath (string filename)
- {
- var filePath = GetFilePath (filename);
- return filePath;
- }
- /*static string GetFilePath (string filename)
- {
- string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
- string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
- var path = Path.Combine(libraryPath, filename);
- return path;
- }*/
- static string GetFilePath (string filename)
- {
- var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
- var filePath = Path.Combine (documentsPath, filename);
- return filePath;
- }
- public void WriteStream (string filename, Stream streamIn)
- {
- var filePath = GetFilePath (filename);
- using (var fs = File.Create (filePath)) {
- streamIn.CopyTo (fs);
- }
- }
- public ImageSource GetImage(string filename){
- Image img = new Image ();
- return img.Source = ImageSource.FromFile (FullPath (filename));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement