public void InsertNewTreePicture(string name, byte[] data) { if (string.IsNullOrWhiteSpace(name)) { return; } if (data == null || data.Length == 0) { return; } string path = GeneratePath(name); string ext = GetExtension(data); string filePath = Path.Combine(_treePath, path + ext); if (Directory.GetFiles(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".*").Length > 0) { return; } Save(filePath, data); TreePicture treePicture = new TreePicture { Name = Path.GetFileNameWithoutExtension(filePath), Image = data }; _treePictures.Add(treePicture.Name, treePicture); }
public ITreePicture LoadTreePicture(string name) { if (!CouldMigrate) { return(null); } TreePicture treePicture = new TreePicture { Name = name }; using (IDbConnection cnx = GetPictureConnectionInternal()) { return(Mapper <TreePicture> .Load(cnx, treePicture)); } }
public void LoadAllTreePicture() { _treePictures.Clear(); if (!Directory.Exists(_treePath)) { return; } foreach (string file in Directory.GetFiles(_treePath, "*.*", SearchOption.AllDirectories)) { TreePicture treePicture = new TreePicture { Name = Path.GetFileNameWithoutExtension(file), Image = File.ReadAllBytes(file) }; if (!_treePictures.ContainsKey(treePicture.Name)) { _treePictures.Add(treePicture.Name, treePicture); } } }