Пример #1
0
        /// <summary>
        /// Returns the list of subdirectories
        /// in the context web directory.
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        /// <param name="onlyPublic">If true restrict to public subdirectories</param>
        public static List <string> MakeSubdirectoryList
            (HttpContext context, bool onlyPublic)
        {
            List <string> list = new List <string>();

            if (context == null)
            {
                return(list);
            }

            string path = FileTools.GetDirectoryPath(context);

            DirectoryInfo thisdir = new DirectoryInfo(path);

            DirectoryInfo[] subdirs = thisdir.GetDirectories();

            foreach (DirectoryInfo di in subdirs)
            {
                string name = di.Name;

                if (onlyPublic)
                {
                    if (!SourceTools.IsPublic(name))
                    {
                        continue;
                    }
                }

                list.Add(name);
            }

            return(list);
        }
Пример #2
0
        /// <summary>
        /// Returns the list of files
        /// that reside in the context web directory
        /// and that match the given file type.
        ///
        /// The filetype should take one of seven values:
        ///   1: Text files
        ///   2: Image files
        ///   3: Viewable files, that is, text and image files
        ///   4: Non-viewable files
        ///   5: Text files plus non-viewable files
        ///   6: Image files plus non-viewable files
        ///   7: All files
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        /// <param name="fileType">The filetype mask</param>
        public static List <string> MakeFileList
            (HttpContext context, int fileType)
        {
            if (context == null)
            {
                return(new List <string>());
            }

            string directorypath = FileTools.GetDirectoryPath(context);

            return(SourceTools.MakeFileList(directorypath, fileType));
        }
Пример #3
0
        /// <summary>
        /// Make the body markup for the AutoImage utility.
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        /// <param name="onlyPublic">If true restrict to public subdirectories</param>
        public static string MakeAutoImageMarkup
            (HttpContext context, bool onlyPublic)
        {
            StringBuilder builder = new StringBuilder();

            // path in the file system
            string directoryPath =
                FileTools.GetDirectoryPath(context);

            // path as a tilde web directory path
            string tildeDirectoryPath =
                HttpContextTools.GetTildeDirectoryPath(context);

            List <string> subdirectoryList =
                HttpContextTools.MakeSubdirectoryList(context, onlyPublic);

            List <string> imageList =
                HttpContextTools.MakeFileList(context, FileTools.IMAGE);

            int M = subdirectoryList.Count;
            int N = imageList.Count;

            // create markup

            builder.Append("\n<p><b>Web Directory: ");
            builder.Append(tildeDirectoryPath);
            builder.Append("</b></p>\n");

            if (M > 0)
            {
                builder.Append("\n<p><b>Subdirectories:</b></p>\n");

                MakeSubdirectoryLinks(builder, subdirectoryList);
            }

            builder.Append("\n<p><b>Image Count in this Web Directory: ");
            builder.Append(N);
            builder.Append("</b></p>\n");

            MakeImageLinks(builder, directoryPath, imageList);

            return(builder.ToString());
        }
Пример #4
0
        /// <summary>
        /// Returns the list of servable files
        /// in the same directory
        /// as the context web directory.
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        public static List <string> MakeServableList(HttpContext context)
        {
            if (context == null)
            {
                return(new List <string>());
            }

            string directorypath = FileTools.GetDirectoryPath(context);

            List <string> filelist =
                SourceTools.MakeFileList(directorypath, FileTools.ALL);

            List <string> servablelist = new List <string>();

            foreach (string name in filelist)
            {
                if (IsServable(name))
                {
                    servablelist.Add(name);
                }
            }

            return(servablelist);
        }