• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Web.HttpServerUtility类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.HttpServerUtility的典型用法代码示例。如果您正苦于以下问题:C# HttpServerUtility类的具体用法?C# HttpServerUtility怎么用?C# HttpServerUtility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpServerUtility类属于System.Web命名空间,在下文中一共展示了HttpServerUtility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AbsoluteDirectoryPathList

        /// <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;
        }
开发者ID:rewanth21,项目名称:freetime,代码行数:42,代码来源:FileListTools.cs


示例2: TextFileStatistics

        /// <summary>
        /// Returns a string for an HTML table with
        ///     number of bytes
        ///     number of lines
        ///     creation date,
        ///     last modification date
        /// for the file with the given tildeFilePath.
        /// </summary>
        /// <param name="server">The server to convert to real file paths</param>
        /// <param name="tildeFilePath">The tilde file path</param>

        public static string TextFileStatistics(HttpServerUtility server, string tildeFilePath)
        {
            StringBuilder builder = new StringBuilder();
            string filePath = null;
            FileInfo info = null;

            if (TildeFilePathExistsAndIsText(server, tildeFilePath, ref filePath, ref info))
            {
                long bytes = info.Length;
                DateTime created = info.CreationTime;
                DateTime modified = info.LastWriteTime;

                long lines = 0;

                using (StreamReader reader = new StreamReader(filePath))
                {
                    while (!reader.EndOfStream)
                    {
                        string foobar = reader.ReadLine();
                        lines++;
                    }
                }

                TildeFilePathStatisticsTable(builder, bytes, lines, created, modified);
            }
            else
            {
                TildeFilePathErrorMessage(builder);
            }

            return builder.ToString();
        }
开发者ID:khanman,项目名称:Web-Development-Experiment,代码行数:43,代码来源:LargeTextTools.cs


示例3: Save

        public static string Save(HttpServerUtility server, Stream stream, string fileName) {

            string fileExtension = Path.GetExtension(fileName);
            string relativePath = $"{RootFileName}/{Unknow}/";
            string savePath = server.MapPath($"~/{relativePath}");

            if (!string.IsNullOrEmpty(fileExtension)) {
                //去掉extension的.
                relativePath = $"{RootFileName}/{fileExtension.Substring(1)}/";
                savePath = server.MapPath($"~/{relativePath}/");
            }

            if (!Directory.Exists(savePath)) {
                Directory.CreateDirectory(savePath);
            }

            string newFileName = Guid.NewGuid().ToString("N") + fileExtension;
            string saveFile = Path.Combine(savePath, newFileName);
            bool success = FileHelper.WriteFile(stream, saveFile);
            string retFile = "";
            if (success) {
                retFile = $"{Address}{relativePath}{newFileName}";
            }

            return retFile;
        }
开发者ID:TheTypoMaster,项目名称:DotNet.Mix,代码行数:26,代码来源:FileStore.cs


示例4: CreateTemplateFileIfNotExists

        /// <summary>
        /// Creates a template file if it does not already exists, and uses a default text to insert. Returns the new path
        /// </summary>
        public string CreateTemplateFileIfNotExists(string name, string type, string location, HttpServerUtility server, string contents = "")
        {
            if (type == RazorC)
            {
                if (!name.StartsWith("_"))
                    name = "_" + name;
                if (Path.GetExtension(name) != ".cshtml")
                    name += ".cshtml";
            }
            else if (type == RazorVb)
            {
                if (!name.StartsWith("_"))
                    name = "_" + name;
                if (Path.GetExtension(name) != ".vbhtml")
                    name += ".vbhtml";
            }
            else if (type == TokenReplace)
            {
                if (Path.GetExtension(name) != ".html")
                    name += ".html";
            }

            var templatePath = Regex.Replace(name, @"[?:\/*""<>|]", "");
            var absolutePath = server.MapPath(Path.Combine(GetTemplatePathRoot(location, App), templatePath));

            if (!File.Exists(absolutePath))
            {
                var stream = new StreamWriter(File.Create(absolutePath));
                stream.Write(contents);
                stream.Flush();
                stream.Close();
            }

            return templatePath;
        }
开发者ID:2sic,项目名称:2sxc,代码行数:38,代码来源:TemplateManager.cs


示例5: Init

        public static void Init(HttpServerUtility server)
        {
            string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
            DefaultConfigPath = server.MapPath(configPath);

            //By default if there's no config let's create a sqlite db.
            string defaultConfigPath = DefaultConfigPath;

            string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
            sqlitePath = server.MapPath(sqlitePath);

            if (!File.Exists(defaultConfigPath))
            {
                ConfigFile file = new ConfigFile(defaultConfigPath);

                file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                file.Save();

                CurrentConfigFile = file;
            }
            else
            {
                CurrentConfigFile = new ConfigFile(defaultConfigPath);
                CurrentConfigFile.Load();
            }

            CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
        }
开发者ID:nzgeek,项目名称:WebGoat.NET,代码行数:29,代码来源:Settings.cs


示例6: WriteLog

        const string Token = "youotech"; //定义一个局部变量不可以被修改,这里定义的变量要与接口配置信息中填写的Token一致

        #endregion Fields

        #region Methods

        /// <summary>
        /// 写日志(用于跟踪),可以将想打印出的内容计入一个文本文件里面,便于测试
        /// </summary>
        public static void WriteLog(string strMemo, HttpServerUtility server)
        {
            string filename = server.MapPath("/log/log.txt");//在网站项目中建立一个文件夹命名logs(然后在文件夹中随便建立一个web页面文件,避免网站在发布到服务器之后看不到预定文件)
            if (!Directory.Exists(server.MapPath("//log//")))
                Directory.CreateDirectory("//log//");
            StreamWriter sr = null;
            try
            {
                if (!File.Exists(filename))
                {
                    sr = File.CreateText(filename);
                }
                else
                {
                    sr = File.AppendText(filename);
                }
                sr.WriteLine(strMemo);
            }
            catch
            {
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }
        }
开发者ID:mildrock,项目名称:wechat,代码行数:36,代码来源:Default.aspx.cs


示例7: transferToError

		/**
		 * Transfers control to the Error page using Server.Transfer, and displays some error information.
		 * 
		 * header: The error page header, ex. "Page not found". HTML in the string is not escaped.
		 * description: A description of the error, ex. "Path /foo/bar.txt not found". HTML in the string is not escaped.
		 * code: The response code of the page, ex. 404.
		 */
		public static void transferToError(HttpServerUtility server, HttpContext context, string header, string description, int code) {
			context.Items.Clear ();
			context.Items ["ErrorPage_title"] = header;
			context.Items ["ErrorPage_desc"] = description;
			context.Items ["ErrorPage_code"] = code;
			server.Transfer ("~/ErrorPage.aspx", false);
		}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:14,代码来源:ErrorPage.aspx.cs


示例8: FileInfo

        /// <summary>
        /// Returns true if the tildeFilePath corresponds to a file that
        /// exists and is a text file.
        /// 
        /// In that case, the filePath and info parameters are initialized.
        /// </summary>
        /// <param name="server">The server to convert to real file paths</param>
        /// <param name="tildeFilePath">The tilde file path</param>
        /// <param name="filePath">The real file path</param>
        /// <param name="info">The FileInfo object</param>
        public static bool TildeFilePathExistsAndIsText
            (HttpServerUtility server,
             string tildeFilePath,
             ref string filePath,
             ref FileInfo info)
        {
            bool error = StringTools.IsTrivial(tildeFilePath);

            if (!error)
            {
                error = !tildeFilePath.StartsWith("~/");
            }

            if (!error)
            {
                int category = FileTools.GetFileCategory(tildeFilePath);
                error = category != FileTools.TEXT;
            }

            if (!error)
            {
                try
                {
                    filePath = server.MapPath(tildeFilePath);
                    info = new FileInfo(filePath);
                    long bytes = info.Length;
                }
                catch
                {
                    error = true;
                }
            }

            return !error;
        }
开发者ID:khanman,项目名称:Web-Development-Experiment,代码行数:45,代码来源:LargeTextTools.cs


示例9: HttpServerUtilityWrapper

 public HttpServerUtilityWrapper(HttpServerUtility httpServerUtility)
 {
     if (httpServerUtility == null) {
         throw new ArgumentNullException("httpServerUtility");
     }
     _httpServerUtility = httpServerUtility;
 }
开发者ID:frenzypeng,项目名称:securityswitch,代码行数:7,代码来源:HttpServerUtilityWrapper.cs


示例10: ICalProducer

 public ICalProducer(List<CalendarEntry> entries, string location, HttpServerUtility server, string personelNumber, string kardexNumber)
 {
     _entries = entries;
     _location = location;
     _server = server;
     _personelNumber = personelNumber;
     _kardexNumber = kardexNumber;
 }
开发者ID:fosterbuster,项目名称:dotNetCOOPTimeScheduleParserProvider,代码行数:8,代码来源:ICalProducer.cs


示例11: Start

    public static void Start(HttpServerUtility server)
    {
      DeNSo.Configuration.BasePath = server.MapPath("~/App_Data");
      DeNSo.Configuration.EnableJournaling = true;

      Session.DefaultDataBase = "densodb_webapp";
      Session.Start();
    }
开发者ID:dronab,项目名称:DensoDB,代码行数:8,代码来源:DensoConfig.cs


示例12: LoadDiskCache

        internal static void LoadDiskCache(HttpServerUtility server)
        {
            var cache = server.MapPath("~/App_Data/api_start2.json");
            if(!File.Exists(cache)) return;

            start2Content = File.ReadAllText(cache);
            start2Timestamp = (long)((File.GetLastWriteTimeUtc(cache) - Utils.UnixTimestamp.Epoch.UtcDateTime).TotalMilliseconds);
        }
开发者ID:trhyfgh,项目名称:OoiSharp,代码行数:8,代码来源:KcsApiStart2Handler.cs


示例13: getDataSetFromExcel

        public static DataSet getDataSetFromExcel(FileUpload FileUpload1, HttpServerUtility Server)
        {
            if (FileUpload1.HasFile)
            {
                string fileName = Path.GetFileName(FileUpload1.FileName);
                string filePath = Server.MapPath("~/Excel/" + fileName);
                string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName);

                try
                {

                    MemoryStream stream = new MemoryStream(FileUpload1.FileBytes);
                    IExcelDataReader excelReader;

                    if (fileExtension == ".xls")
                    {
                        excelReader = ExcelReaderFactory.CreateBinaryReader(stream);

                        excelReader.IsFirstRowAsColumnNames = true;
                        DataSet result = excelReader.AsDataSet();

                        DataTable myTable = result.Tables[0];

                        excelReader.Close();
                        return result;
                    }
                    else if (fileExtension == ".xlsx")
                    {
                        excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                        //excelReader.IsFirstRowAsColumnNames = true;
                        DataSet result = excelReader.AsDataSet();

                        DataTable myTable = result.Tables[0];

                        excelReader.Close();
                        return result;
                    }
                    else if (fileExtension == ".csv")
                    {
                        //Someone else can implement this
                        return null;
                    }
                    else
                    {
                        throw new Exception("Unhandled Filetype");
                    }
                }
                catch
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
开发者ID:redtchits,项目名称:RCM,代码行数:58,代码来源:Utils.cs


示例14: Register

 public static void Register(HttpServerUtility server)
 {
     ConstantManager.LogPath = server.MapPath("~/Areas/Admin/LogFiles/");
     ConstantManager.ConfigPath = server.MapPath("~/Areas/Admin/AdminConfig.xml");
     ConstantManager.SavedPath = server.MapPath("~/Areas/Admin/SavedPages");
     ConstantManager.TrainingFilePath = server.MapPath("~/UploadedExcelFiles/ProductName.txt");
     ConstantManager.DistanceFilePath = server.MapPath("~/CalculateMarketDistance.xml");
     ConstantManager.IsParserRunning = false;
 }
开发者ID:dimparis,项目名称:smart-buy,代码行数:9,代码来源:ConstantConfig.cs


示例15: ApplicationError

        public ApplicationError(HttpServerUtility server, HttpResponse response, HttpContext context)
        {
            HttpServerUtility = server;
            HttpResponse = response;
            HttpContext = context;

            LastException = HttpServerUtility.GetLastError() as HttpException;
            StatusCode = LastException == null ? 500 : LastException.GetHttpCode();
        }
开发者ID:tylermercier,项目名称:mvc_template,代码行数:9,代码来源:ApplicationError.cs


示例16: ProcessorArgs

        internal ProcessorArgs([NotNull] BootcampCore bootcampCore, HttpServerUtility server, BootcampMode mode, string sitecoreVersion)
        {
            Assert.ArgumentNotNull(bootcampCore, "bootcampCore");
              Assert.ArgumentNotNull(server, "server");

              this.BootcampCore = bootcampCore;
              this.Mode = mode;
              this.Server = server;
              this.SitecoreVersion = sitecoreVersion;
        }
开发者ID:Sitecore,项目名称:Sitecore-Bootcamp,代码行数:10,代码来源:ProcessorArgs.cs


示例17: Configure

 public static void Configure(HttpServerUtility server)
 {
     Mapper.Initialize(cfg =>
     {
         cfg.AddProfile(new DepartmentProfile(server));
         cfg.AddProfile(new PageProfile());
         cfg.AddProfile(new UserProfile());
         cfg.AddProfile(new RoleProfile());
     });
 }
开发者ID:torero-vlg,项目名称:docfis,代码行数:10,代码来源:AutoMapperWebConfiguration.cs


示例18: UploadImagem

 public UploadImagem(FileUpload arquivo, string path, HttpServerUtility utilitarioHttp, int tamanhoArquivoKB, int largura, int altura)
 {
     this._arquivo = arquivo;
     this._path = path;
     this._utilitarioHttp = utilitarioHttp;
     this._tamanhoArquivoKB = tamanhoArquivoKB * 1024;
     this._largura = largura;
     this._altura = altura;
     this.PreencherExtensoesValidas();
 }
开发者ID:brodock,项目名称:genova-project,代码行数:10,代码来源:UploadImagem.cs


示例19: PopulateSampleFiles

		public void PopulateSampleFiles(HttpServerUtility server, string wildcard, DropDownList ddl)
		{
			string sampleDir = server.MapPath("SampleFiles");
			ddl.Items.Add(new ListItem("Choose sample", ""));
			DirectoryInfo di = new DirectoryInfo(sampleDir);
			foreach (FileInfo f in di.GetFiles(wildcard))
			{
				ddl.Items.Add(new ListItem(Path.GetFileNameWithoutExtension(f.Name), f.Name));
			}
		}
开发者ID:relaxar,项目名称:reko,代码行数:10,代码来源:WebDecompilerHost.cs


示例20: RegisterStandard

        public static Bootstrapper RegisterStandard(this Bootstrapper bootstrapper, HttpServerUtility server)
        {
            FileSystemStorage.StoragePath = server.MapPath("~/Storage");
            FormsCore.Instance.BaseUrl = "http://localhost:36258";

            bootstrapper.UnityContainer
                .RegisterType<IFileStorage, FileSystemStorage>()
                .RegisterType<ILogger, TraceLogger>();

            return bootstrapper;
        }
开发者ID:jacklau88,项目名称:Forms,代码行数:11,代码来源:BootstrapperExtensions.cs



注:本文中的System.Web.HttpServerUtility类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web.HttpServerUtilityBase类代码示例发布时间:2022-05-26
下一篇:
C# Web.HttpResponseBase类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap