Example #1
0
        public ProjectZipedDirectoryDto GetUserProject(Guid Id, GetProjectDto info)
        {
            User user = ManagerActionControl(Id);
            WorkingDir dir = _context.WorkingDirs.FirstOrDefault(e => e.OwnerId == info.User && e.ProjectId == info.Project);
            if (dir == null)
            {
                throw  new Exception();
            }
            String ZipPath = PathGenerator.GetPathForZip(dir.Path);
            ZipFile.CreateFromDirectory(dir.Path,ZipPath);
            byte[] data;
            using (var f = new FileStream(ZipPath, FileMode.Open))
            {
                  data= new byte[f.Length];
                  f.Read(data, 0, (int) f.Length);

            }
            System.IO.File.Delete(ZipPath);
            return new ProjectZipedDirectoryDto()
            {
                Data = data,
                Name = dir.Project.Name
            };
        }