public override FileDescriptor UploadFile(string siteId, bool isTemplate, string relativePath, string fileName, byte[] fileContents)
        {
            FaultContract Fault        = null;
            string        physicalPath = FileUtils.GetPhysicalPathForId(siteId, isTemplate, relativePath, out Fault);

            if (Fault != null)
            {
                throw new Exception(Fault.Message);
            }

            if (!System.IO.Directory.Exists((physicalPath)))
            {
                throw new Exception("Unable to upload file");
            }

            string filePath = string.Format("{0}\\{1}", physicalPath, fileName);

            FileExplorerUtility.UploadFile(filePath, fileContents, out Fault);
            FileDescriptor newFile = new FileDescriptor();

            newFile.FileName = fileName;
            if (relativePath != null)
            {
                newFile.RelativePath = string.Format("{0}/{1}", relativePath, fileName);
            }
            else
            {
                newFile.RelativePath = fileName;
            }
            return(newFile);
        }
        protected override FileDescriptor[] GetFiles(string siteId, bool isTemplate, string relativePath, string[] fileExts)
        {
            FaultContract Fault        = null;
            string        physicalPath = FileUtils.GetPhysicalPathForId(siteId, isTemplate, relativePath, out Fault);

            if (Fault != null)
            {
                throw new Exception(Fault.Message);
            }

            if (!System.IO.Directory.Exists((physicalPath)))
            {
                throw new Exception("Unable to find files");
            }

            List <FileDescriptor> allFiles = new List <FileDescriptor>();

            string[] dirs = FileExplorerUtility.GetDirectories(physicalPath);
            if (dirs != null && dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    if (string.IsNullOrEmpty(dir))
                    {
                        continue;
                    }
                    FileDescriptor fileInfo = new FileDescriptor();
                    string         fileName = dir;
                    int            pos      = fileName.LastIndexOf('\\');
                    if (pos > -1)
                    {
                        fileName = fileName.Substring(pos + 1);
                    }
                    fileInfo.FileName = fileName;
                    fileInfo.IsFolder = true;
                    if (!string.IsNullOrEmpty(relativePath))
                    {
                        fileInfo.RelativePath = string.Format("{0}/{1}", relativePath, fileName);
                    }
                    else
                    {
                        fileInfo.RelativePath = fileName;
                    }
                    allFiles.Add(fileInfo);
                }
            }

            string[] files = FileExplorerUtility.GetFiles(physicalPath, fileExts);
            if (files != null && files.Length > 0)
            {
                foreach (string file in files)
                {
                    FileDescriptor fileInfo = new FileDescriptor();
                    string         fileName = file;
                    int            pos      = fileName.LastIndexOf('\\');
                    if (pos > -1)
                    {
                        fileName = fileName.Substring(pos + 1);
                    }
                    fileInfo.FileName = fileName;

                    if (!string.IsNullOrEmpty(relativePath))
                    {
                        fileInfo.RelativePath = string.Format("{0}/{1}", relativePath, fileName);
                    }
                    else
                    {
                        fileInfo.RelativePath = fileName;
                    }
                    allFiles.Add(fileInfo);
                }
            }

            return(allFiles.ToArray());
        }