public bool Delete(Entities.Directory d) { string path = d.BuildPath(); if (System.IO.Directory.GetFiles(path).Count() > 0) { throw new Exceptions.DirectoryNotEmptyException(d); } try { System.IO.Directory.Delete(path); } catch (System.IO.DirectoryNotFoundException) { throw new Exceptions.PathNotFoundException(d); } catch (System.IO.DriveNotFoundException) { throw new Exceptions.PathNotFoundException(d); } catch (Exception) { throw new Exceptions.GeneralException(d, d.GetType()); } return(true); }
//How to you know that these are the only errors that will be thrown? //Do you not need a general exception to handle just in case? public Entities.Directory Get(Entities.Directory id) { string path = id.BuildPath(); System.IO.DirectoryInfo d; try { d = new System.IO.DirectoryInfo(path); } catch (System.IO.DirectoryNotFoundException) { throw new Exceptions.PathNotFoundException(id); } catch (System.IO.DriveNotFoundException) { throw new Exceptions.PathNotFoundException(id); } return(_Mapper.ToProviderEntity(d)); }
public Entities.Directory Create(Entities.Directory o) { var d = System.IO.Directory.CreateDirectory(o.BuildPath()); return(_Mapper.ToProviderEntity(d)); }