【asp.net 获取指定文件夹下所有子目录及文件(树形)】教程文章相关的互联网学习教程文章

asp.net无法获取iis目录的问题解决方法【图】

如果你有一个需要偶尔发送邮件的Asp.Net的网站,可能会有代码长的和下面的很像: 代码如下://这是简写,并非实际项目代码public void Send(string from, string to, string subject, string body){ var msgMail = new MailMessage(from, to, subject, body); msgMail.IsBodyHtml = true; var server = new SmtpClient("localhost"); server.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; server.Us...

ASP.NET汉字转拼音 - 输入汉字获取其拼音的具体实现【图】

前不久看到有的朋友实现对商品名称拼音的录入,发现他的实现方式是手动输入的,—_—#、同志们,福利来了! 微软为了开发者实现国际化语言的互转,提供了Microsoft Visual Studio International Pack,这个扩展包里面有中文、日文、韩文、英语等各国语言包,并提供方法实现互转、获取拼音、获取字数、甚至获取笔画数等等。 在这里示例讲的是输入汉字,获取其拼音,获取拼音和获取拼音首字母实现效果分别如下:首先,去微软官网下载...

asp.net获取网站绝对路径示例

代码如下:VirtualPathUtility.ToAbsolute( " ~/ " )HttpRuntime.AppDomainAppVirtualPathRequest.ApplicationPathPage.ResolveUrl( " ~ " ) 以上代码生成的结果如下:当以网站的方式访问时,结果如下: 代码如下:VirtualPathUtility.ToAbsolute("~/") = /HttpRuntime.AppDomainAppVirtualPath = /Request.ApplicationPath = /Page.ResolveUrl("~") = / 当以虚拟目录(http://localhost:806/web2/url.aspx)访问时,结果如下:代码...

获取根目录的URL例如http://localhost:51898

代码如下:public static string GetRootURI() { string AppPath = ""; HttpContext HttpCurrent = HttpContext.Current; HttpRequest Req; if (HttpCurrent != null) { Req = HttpCurrent.Request; string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority); if (Req.ApplicationPath == null || Req.ApplicationPath == "/") //直接安装在 Web 站点 AppPath = UrlAuthority; else //安装在虚拟子目录下 AppPath = UrlAut...

asp.net获取网站目录物理路径示例

页面后台cs文件的相对网站根目录的路径/view/Atlas 代码如下:string rootPath1= Server.MapPath("~"); string rootPath2 = Request.ApplicationPath; string path1 = Server.MapPath("upload"); string path2 = Server.MapPath(""); string path3 = Server.MapPath("."); string path4 = Server.MapPath(".."); string path5 = Server.MapPath(Request.ServerVariables["PATH_INFO"]); 结果 代码如下:string rootpath1= "F:\\AS...

利用sender的Parent获取GridView中的当前行(获取gridview的值)【图】

获取GridView当行有好几个方法:1 加RowCommand事件中,判断请求的发出按钮控件名,根据传递的参数来获取当前行中我们需要的参数。2 GridView设置datakeynames方式。以上方法实现不再累赘。 今天给大家介绍一种最方便,也最满足日常思维的好办法:采用控件事件的sender的Parent来获取cell对象,再取cell的上级对象,也就是row对象了。简单吧! 示例如下:在第三列中放了一个模板列,放入了一个CheckBox,想法是在选中时,设置第四列L...

ashx中使用session的方法(获取session值)

WEB开发,在一般处理程序中,很容易得到 Request和Response对象,如: 代码如下:HttpRequest _request = context.Request; HttpResponse _response = context.Response; 但是要得到 Session的值就没有那么简单了。 比如如果要在ashx得到保存在Session中的登录用户信息 Session["LoginUser"] 如果仅仅使用 context.Session["LoginUser"] 的话,是会报 “未将对象引用设置到对象的实例”的异常! 具体要使用下列方法:代码如下:usin...

.net获取本机公网IP地址示例

代码很简单,直接看代码 代码如下:using System;using System.Net;using System.Text.RegularExpressions; namespace Keleyi.Com{ public class GetInternetIP { public static string GetIP() { using (var webClient = new WebClient()) { try { var temp = webClient.DownloadString("http://iframe.ip138.com/ic.asp"); ...

asp.net使用jQuery获取RadioButtonList成员选中内容和值示例

代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web.Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script src="jquery-1.8.2.min.js" type="text/javascript"></script> <link href="B...

C#获取当前页面的URL示例代码

本实例的测试URL:http://www.mystudy.cn/web/index.aspx 1、通过C#获取当前页面的URL 代码如下:string url = Request.Url.AbsoluteUri; //结果: http://www.mystudy.cn/web/index.aspx string host = Request.Url.Host; //结果:www.mystudy.cn string rawUrl = Request.RawUrl; //结果:/web/index.aspx string localPath = Request.Url.LocalPath; //结果:/web/index.aspx 2、通过Javascript获取当前页面的URL 代码如下:var...

asp.net获取select值的方法

代码如下:<select runat="server" class="xgxxbd" id="wyzs"> <option value="6">托福</option> </select> wyzs.Items[wyzs.SelectedIndex].Text;//获取文本 //获取值 wyzs.Items[wyzs.SelectedIndex].value; wyzs.value

12小时制和24小时制获取当天零点的问题探讨

最近在写定时服务的时候,要获取当天的零点这个时间,但是是这样获取的代码如下:DateTime dt = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")+" 00:00:00");Console.WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss")); 在本地,测试,QA环境测试了均没有问题,但是上了公网服务器以后,这个定时服务,就出问题了;写了下日志,竟然发现获取当天的零点,拼起来后获取的时间是前一天的零点,原来服务器时间是12小时制的,本地环...

.net 获取浏览器Cookie(包括HttpOnly)实例分享

一、接口文件代码如下:using System; using System.ComponentModel; using System.Net; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; namespace CookieHandler { internal sealed class INativeMethods { #region enums public enum ErrorFlags { ERROR_INSUFFICIENT_BUFFER = 122, ERROR_INVA...

TreeView无刷新获取text及value实现代码

前台代码: 代码如下:<html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title> <style type="text/css"> #middle{ top:0; left:0;background-color:#fff; position:absolute; z-index:2; filter:alpha(opacity=60); display:none;} #showTree{ width:300px; height:200px; position:fixed; z-index:2; display:none; border:1px solid red;} </style> <script type="text...

Asp.Net获取网站截图的实例代码

代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { private WebBrowser _webBrowser; public Form1() { InitializeComponent(); } public void GetThumbNail(string url...