public static DataTable GetFoldersAndFiles(int moduleId, int parentId)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("ID", typeof(string));
            dt.Columns.Add("filename", typeof(string));
            dt.Columns.Add("OriginalFileName", typeof(string));
            dt.Columns.Add("Description", typeof(string));
            dt.Columns.Add("size", typeof(int));
            dt.Columns.Add("type", typeof(int));
            dt.Columns.Add("DownloadCount", typeof(string));
            dt.Columns.Add("modified", typeof(DateTime));
            dt.Columns.Add("username", typeof(string));

            DataRow dr;

            using (IDataReader reader = GetSharedFolders(moduleId, parentId))
            {
                while (reader.Read())
                {
                    dr                     = dt.NewRow();
                    dr["ID"]               = reader["FolderID"].ToString() + "~folder";
                    dr["filename"]         = reader["FolderName"];
                    dr["OriginalFileName"] = string.Empty;
                    dr["Description"]      = string.Empty;
                    dr["size"]             = reader["SizeInKB"].ToString();
                    dr["type"]             = "0";
                    dr["DownloadCount"]    = string.Empty;
                    dt.Rows.Add(dr);
                }
            }

            using (IDataReader reader = SharedFile.GetSharedFiles(moduleId, parentId))
            {
                while (reader.Read())
                {
                    dr                     = dt.NewRow();
                    dr["ID"]               = reader["ItemID"].ToString() + "~file";
                    dr["filename"]         = reader["FriendlyName"];
                    dr["OriginalFileName"] = reader["OriginalFileName"];
                    dr["Description"]      = reader["Description"];
                    dr["size"]             = reader["SizeInKB"].ToString();
                    dr["type"]             = "1";
                    dr["modified"]         = Convert.ToDateTime(reader["UploadDate"]);
                    dr["username"]         = reader["UserName"].ToString();
                    dr["DownloadCount"]    = reader["DownloadCount"].ToString();
                    dt.Rows.Add(dr);
                }
            }


            dt.AcceptChanges();

            return(dt);
        }
        public void DeleteAllFiles(string fileBasePath)
        {
            // method implemented by Jean-Michel 2008-07-31

            // TODO: implement check whether versioning is enabled before calling this method
            // if we are keeping versions we should not delete the files

            if (FolderId == -1)
            {
                return;
            }

            ArrayList folders = new ArrayList();
            ArrayList files   = new ArrayList();

            using (IDataReader reader = SharedFile.GetSharedFiles(ModuleId, FolderId))
            {
                while (reader.Read())
                {
                    files.Add(Convert.ToInt32(reader["ItemID"]));
                }
            }

            using (IDataReader reader = SharedFileFolder.GetSharedFolders(ModuleId, FolderId))
            {
                while (reader.Read())
                {
                    folders.Add(Convert.ToInt32(reader["FolderID"]));
                }
            }

            foreach (int id in files)
            {
                SharedFile sharedFile = new SharedFile(ModuleId, id);
                sharedFile.Delete(fileBasePath);
            }

            foreach (int id in folders)
            {
                SharedFileFolder folder = new SharedFileFolder(ModuleId, id);
                folder.DeleteAllFiles(fileBasePath);
                SharedFileFolder.DeleteSharedFileFolder(id);
            }
        }