File size: 1,517 Bytes
b1b3bae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
using DWSIM.Interfaces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DWSIM.SharedClassesCSharp.FilePicker.Windows
{
public class WindowsFile : IVirtualFile
{
private string _filePath;
public string Filename { get => Path.GetFileName(_filePath); }
public string FullPath => _filePath;
public string ParentUniqueIdentifier => throw new NotImplementedException();
public WindowsFile(string filePath)
{
_filePath = filePath;
}
public string ReadAllText()
{
return File.ReadAllText(_filePath);
}
public Stream OpenRead()
{
return File.OpenRead(_filePath);
}
public void Write(Stream stream)
{
stream.Seek(0, SeekOrigin.Begin);
using (var fileStream = new FileStream(_filePath, FileMode.Create, FileAccess.Write))
{
stream.CopyTo(fileStream);
}
}
public void Write(string localFile)
{
File.Copy(localFile, _filePath);
}
public string GetExtension()
{
return Path.GetExtension(_filePath);
}
public void Delete()
{
File.Delete(_filePath);
}
public bool Exists()
{
return File.Exists(_filePath);
}
}
}
|