コード例 #1
0
        public bool Update(Entities.DirectoryUpdate o)
        {
            string path = o.BuildPath();
            o.PathParts = o.MoveTo;
            string destPath = o.BuildPath();

            System.IO.Directory.Move(System.IO.Path.Combine(path, o.Name), System.IO.Path.Combine(destPath, o.RenameTo));

            return true;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        //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);
        }
コード例 #4
0
 public PathNotFoundException(Entities.Directory d)
 {
     _Path = d.BuildPath();
 }
コード例 #5
0
 public Entities.Directory Create(Entities.Directory o)
 {
     var d = System.IO.Directory.CreateDirectory(o.BuildPath());
     return _Mapper.ToProviderEntity(d);
 }