Example #1
0
        public FileItem ResolveFileResourcePath2(string submittedFilePath, FileSystemTask context)
        {
            if (String.IsNullOrEmpty(submittedFilePath))
            {
                throw new InvalidResourcePathException("An empty or null string is not a valid file path");
            }

            //make sure we operate on absolute paths
            var absolutePath = PathUtil.GetAbsolutePath(submittedFilePath, RootDirectory);

            if (IsRootPath(absolutePath))
            {
                throw new InvalidResourcePathException("Invalid path submitted: " + submittedFilePath);
            }

            var             localFile   = new FileInfo(absolutePath);
            VirtualFileInfo virtualFile = localFile.CreateFileResourceInfo();

            var item = new FileItem(localFile, virtualFile);

            //convert to relative paths if required (also prevents qualified paths in validation exceptions)
            if (UseRelativePaths)
            {
                item.MakePathsRelativeTo(RootDirectory);
            }

            ValidateFileRequestAccess(item, submittedFilePath, context);
            return(item);
        }
        public  FileItem ResolveFileResourcePath2(string submittedFilePath, FileSystemTask context) {
            if (String.IsNullOrEmpty(submittedFilePath)) {
                throw new InvalidResourcePathException("An empty or null string is not a valid file path");
            }

            //make sure we operate on absolute paths
            var absolutePath = PathUtil.GetAbsolutePath(submittedFilePath, RootDirectory);

            if (IsRootPath(absolutePath)) {
                throw new InvalidResourcePathException("Invalid path submitted: " + submittedFilePath);
            }

            var localFile = new FileInfo(absolutePath);
            VirtualFileInfo virtualFile = localFile.CreateFileResourceInfo();

            var item = new FileItem(localFile, virtualFile);

            //convert to relative paths if required (also prevents qualified paths in validation exceptions)
            if (UseRelativePaths) item.MakePathsRelativeTo(RootDirectory);

            ValidateFileRequestAccess(item, submittedFilePath, context);
            return item;
        }