コード例 #1
0
        private void CommonCode(HttpServerUtility server, string tildeFilePath)
        {
            _path = tildeFilePath;

            if (_path[0] != '~')
            {
                return;
            }

            if (!SourceTools.OKtoServe(tildeFilePath, true))
            {
                return;
            }

            try
            {
                string   filePath = server.MapPath(tildeFilePath);
                FileInfo info     = new FileInfo(filePath);
                _size  = info.Length;
                _date  = info.MostRecentTime();
                _valid = true;

                int  category = FileTools.GetFileCategory(_path);
                bool image    = category == FileTools.IMAGE;

                if (image)
                {
                    using (FileStream stream =
                               new FileStream(filePath, FileMode.Open, FileAccess.Read))
                    {
                        try
                        {
                            Bitmap bitmap = new Bitmap(stream);
                            _width  = bitmap.Width;
                            _height = bitmap.Height;
                        }
                        catch { }
                    }
                }
            }
            catch { }
        }
コード例 #2
0
        /// <summary>
        /// First converts tildeDirectoryPath to lowercase.
        ///
        /// Then uses the server to convert tildeDirectoryPath
        /// to an absolute base directory path.
        ///
        /// Then produces the list of absolute directory paths
        /// whose tree roots itself at this base path.
        ///
        /// If there is an error then may return an empty list.
        /// </summary>
        public static List <string> AbsoluteDirectoryPathList
            (HttpServerUtility server, string tildeDirectoryPath)
        {
            List <string> list = new List <string>();

            string path = tildeDirectoryPath.ToLower();

            if (StringTools.IsTrivial(path))
            {
                goto returnstatement;
            }

            if (path[0] != '~')
            {
                goto returnstatement;
            }

            int n = path.Length;

            if (path[n - 1] != '/')
            {
                path = path + '/';
            }

            if (!SourceTools.OKtoServe(path, true))
            {
                goto returnstatement;
            }

            try
            {
                string directoryPath = server.MapPath(path);
                AbsoluteDirectoryPathListHelper(list, directoryPath);
            }
            catch { }


returnstatement:

            return(list);
        }