- C# / .NET 在类中使用Server.MapPath
自我修炼的小石头
c#ui
直接在类中使用Server.MapPath会出现错误,这是由于类中不能直接使用System.Web.UI.Page的非静态函数造成的。解决方法有两种:方法一、使类继承System.Web.UI.Page类classCFoo:System.Web.UI.Page在使用方法一时请注意:C#中,派生类只能从一个类中继承。换句话说,如果该类已经继承了其他类,则不能再继承Page类,只能使用第二种方法。方法
- Asp.Net 在类中使用Server.MapPath(随手笔记)
无味无感
.NETFramework
C#在类中使用Server.MapPath直接在类中使用Server.MapPath会出现错误,这是由于类中不能直接使用System.Web.UI.Page的非静态函数造成的。解决方法有两种:解决方案:方案1:使类继承System.Web.UI.Page类classCFoo:System.Web.UI.Page在使用方法一时请注意:C#中,派生类只能从一个类中继承。换句话说,如果该类已经继承了其他
- DataSet 读取xml文件
Joson.e8love
datasetxmlobjectstringpathc
DataSetds=newDataSet();ds.ReadXml(Server.MapPath(NetShop.Config.DbConfigs.GetSitePath+"images/flashdata/flash.config"));DataRow[]drs=ds.Tables[0].Select("","[SortOrder]ASC");//返回的是个DataRow[]://DataRow
- loniczip
live for myself
java前端服务器
if(!Directory.Exists(Server.MapPath(webUploadFile))){Directory.CreateDirectory(Server.MapPath(webUploadFile));}//stringpath=Server.MapPath(webUploadFile+filename);//获取存储的目标地址using(varzip=newZipFile(En
- Spire.doc读取模板文档,并在书签处插入内容
阿发博客
Spire.doc.net.netcorec#Spire.doc.netword
在书签位置插入文字//加载模板文档Documentdocument=newDocument(Server.MapPath("~/File/评价结果.doc"));//创建书签导航器BookmarksNavigatorbn=newBookmarksNavigator(document);//添加一个section到文档SectionnewSec=document.AddSection();//目标内
- 上传的问题(FileUpload控件上传不支持给定路径的格式 问题解决 )
weixin_30399155
stringfilepath=Server.MapPath("~/upload"); HttpFileCollectionuploadFile=Request.Files; for(inti=0;i0) { Label1.Text=""; Label
- C#中如何调整图像大小
fangyuan621
MicrosoftVisualStudioC#c#
1.首先要获取你想要调整大小的图像:stringpath=Server.MapPath(“~/Images”);System.Drawing.Imageimg=System.Drawing.Image.FromFile(string.Concat(path,”/3904.jpg”));2.将图像转换为Bitmap:Bitmapb=newBitmap(img);3.创建一个调整图像大小的方法priv
- c# npoi创建数据有效性约束制定列和单元格分别设置
葩熊
数据库前端c#
publicActionResultExport(){varcodesstringtemplateFileName=Path.Combine(Server.MapPath("/ExcelTemplate"),"Auto.xlsx");varfileName=@"Auto.xlsx";ExportExcelXlsxHelperex=newExportExcelXlsxHelper();ex.Init
- C#中判断文件夹或文件是否存在的方法
BeanGo
WPFc#开发语言后端
一、根据虚拟路径获取文件物理路径:stringsavePath=Server.MapPath("~/Uploads/RemoteDatum/");二、判断文件夹是否存在if(!System.IO.Directory.Exists(@"E:\Files")){System.IO.Directory.CreateDirectory(@"E:\Files");//不存在就创建文件夹}三、判断文件是否存在
- ASP.NET 操作XML文件
HappySheep欢乐小羊
XML示例文件实例化(new)一个XML文档对象:XmlDocumentxml=newXmlDocument();载入实例化的XML对象:xml.Load(Server.MapPath("test.xml"));获取实例化的XML对象的节点:XmlNoderoot=xml.SelectSingleNode("root");获取节点的子节点列表:XmlNodeListrootlist=root.Ch
- EPPlus导出excel实例及设置工作簿比例
DunDunM
publicvoidPrintExcel(Listdatalist,Listzuzhilist,Listchuwailist){//创建excelstringfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".xlsx";stringnewpath=Server.MapPath("/excel/PrintExcel/")+filename;File
- ASP.NET MVC获取路径并下载的问题
CyborgNO1
最近在做一个ASP.NETMVC项目,有一个功能是实现生成excel文件并下载。在生成excel文件时,总是会因为路径问题,导致无法正确的写道文件位置。在网上查了给种方法,一直在说用Server.MapPath()。但是在我的项目中,是没有这个方法。对于我这种小白来说,当然是不知道原因了。最后在无意间发如何在ASP.NetCore中为Server.MapPath获取绝对路径的内同,于是就按照这种方
- C# 调用exe 传递参数
sqh001
System.Diagnostics.Processproc=newSystem.Diagnostics.Process();proc.StartInfo.FileName=Path.Combine(Server.MapPath("/"),"Office2Pdf.exe");proc.StartInfo.Arguments=string.Format("{0}{1}",officePath,p
- ASP.Net core 中Server.MapPath的替换方法
shanghaimoon
asp.netcorewebasp.net后端c#
最近忙着将原来的asp.net项目迁移到asp.netcore平台,整体还比较顺利,但其中也碰到不少问题,其中比比较值得关注的一个问题是,在netcore平台中,System.Web程序集已经取消了,要获取HttpContext并不是太容易,好在通过依赖注入,还是可以得到的,具体方法不在本文的讨论范围,大家可以自行百度。但是在得到了netcore版本的HttpContext后,发现已经不再有Ser
- error CS0103: 当前上下文中不存在名称“Server”; error CS0103: 当前上下文中不存在名称“Path”;error CS0103: 当前上下文中不存在名称“XXX”
认真看海
c#错误记录
Server.MapPath()的全名是System.Web.HttpContext.Current.Server.MapPath()。有时在程序调试时会提示“当前上下文中不存在名称“Server””错误,从而不支持函数Server.MapPath()的使用。尽管引用了命名空间“usingSystem.Web;”也是无济于事,此时就需要使用其全名,或者是当前使用Server.MapPath()函数
- c#将文件流转成pdf,并保存文件
qq_36276758
c#后台功能
最近比较忙,有一点时间,可以总结一下前几天遇到的问题,c#将从数据库中读取的base64流生成pdf,并保存文件byte[]fileData=(byte[])dt.Rows[0]["fileData"];stringfileName=DateTime.Now.ToString("yyyyMMddhhmmss")+".pdf";StringdirPath=Server.MapPath("/print
- asp.net web api2设置默认启动登录页面的方法
1.在Global.asax文件中添加Application_BeginRequest方法,如下如所示:publicclassWebApiApplication:HttpApplication{protectedvoidApplication_Start(){log4net.Config.XmlConfigurator.Configure(newFileInfo(Server.MapPath("~
- c# mysql 1062_C#中MySQL函数用DATASET 和 MySqlDataAdapter 操作数据库
weixin_39915267
c#mysql1062
[如果一门程序设计语言不支持数据库操作的话,其很难在现在的世界中存活下来。C#语言提供了丰富的数据库操作类库,极大地方便了对数据库的操作。在C#中,常用的有三种访问1.C#中调用MYSQL数据库时,我用的是MySQLDriverCS这个方法.一般的查询可以方便执[stringdbPath=@"Data\dbTest.mdb";stringdb=Server.MapPath(dbPath);stri
- ASP.NET MVC创建XML文件并实现元素增删改
如果创建如下的XML:darren创建XML文件在HomeController中,在根目录下创建new.xml文件:publicActionResultIndex(){returnView();}[HttpPost]publicActionResultAddXml(){stringpath=Server.MapPath("~/new.xml");XDocumentdoc=newXDocument(
- C#中调整图像大小的步骤详解
在本篇文章中,我将介绍如何在C#中来调整你想要的图像大小。要实现这一目标,我们可以采取以下几个步骤:1.首先要获取你想要调整大小的图像:stringpath=Server.MapPath("~/Images");System.Drawing.Imageimg=System.Drawing.Image.FromFile(string.Concat(path,"/3904.jpg"));2.将图像转换
- C# MVC 获取程序中 目录 或虚拟目录的实际文件目录路径
f5df0a516b61
System.Web.HttpContext.Current.Request.PhysicalApplicationPath;这个只能取得当前项目的根目录,也就是http://www.a.com/的根目录Server.MapPath("~/uploads");这个可以获取实际存在在项目中的uploads目录,也可以获取在IIS关联的虚拟目录
- asp.net简单读取xml文件信息
LMAOhuaNL
C#asp.Net
//以下是循环读取xml文件中节点的值 XmlDocumentxmlDoc=newXmlDocument(); xmlDoc.Load(Server.MapPath("Student1.xml"));//加载xml XmlNodeListNodeList=xmlDoc.SelectNodes(
- 最大在线人数统计
MRman0404
数据库
global.asax:protectedvoidSession_Start(Objectsender,EventArgse){Application.Lock();DataSetobjDataSet=newDataSet()objDataSet.ReadXml(Server.MapPath("database/count.xml"));if(Convert.ToInt32(objDataSet.
- C# 上传RAR文件 解压 获取解压后的文件名称
下一秒_待续
C#类库方法
此方法适用于C盘windows文件夹中有WinRAR.exe文件if(fileExt.ToUpper()==".RAR"){stringzpath=Server.MapPath("~/SendFileZIP/");//不存在文件夹时创建文件夹if(!Directory.Exists(zpath)){Directory.CreateDirectory(zpath);}//导入rar压缩文件时,清空S
- 上传Rar文件
PatyTime
C#
if(fileExt.ToUpper()==".RAR"){stringzpath=Server.MapPath("~/SendFileZIP/");//不存在文件夹时创建文件夹if(!Directory.Exists(zpath)){Directory.CreateDirectory(zpath);}//导入rar压缩文件时,清空SendFileZIP文件夹里面所有的文件DirectoryInf
- 关于Server.MapPath()的命名空间
newnazi
代码
下面是c#连接access数据库的一个示例,其中用到了access数据库,大家也可以看看哦.asp.net-C#连接Access数据库连接字符串:"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+System.Web.HttpContext.Current.Server.MapPath("App_Data\tbk.mdb;PersistSecurityI
- access最快速的批量导入SQL的方法 使用SqlBulkCopy
emailqjc
.NET
access最快速的批量导入SQL的方法使用SqlBulkCopy2008-11-2223:51stringfilename=DateTime.Now.ToString("yyyyMMdd")+".mdb";stringtablename=DateTime.Now.ToString("yyyyMMdd");if(File.Exists(Server.MapPath("/tempmdb/"+file
- ASPNET Core 中获取应用程序物理路径
十年河东,十年河西,莫欺骚年穷
.netcore
如果要得到传统的ASP.Net应用程序中的相对路径或虚拟路径对应的服务器物理路径,只需要使用使用Server.MapPath()方法来取得Asp.Net根目录的物理路径,如下所示://ClassicASP.NETpublicclassHomeController:Controller{publicActionResultIndex(){stringphysicalWebRootPath=Serve
- asp连接数据库示例
xiang588
技术文章
asp连接Access数据库(OleDb)setconn=server.createobject("adodb.connection")dbPath="config/bloo.mdb"connStr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath(DBpath)conn.openconnStrasp连接SQLServer数
- Webform(文件上传)
weixin_30454481
uic#
1.HTML编码:2.控件:FileUpload它是用来选择要上传的文件,还需要一个按钮来将选中的文件上传到服务器上stringpath="images/"+FileUpload1.FileName;FileUpload1.SaveAs(Server.MapPath(path));优化1:文件保留原有名称和后缀stringpath="images/"+FileUpload1.FileName;优化
- ASM系列五 利用TreeApi 解析生成Class
lijingyao8206
ASM字节码动态生成ClassNodeTreeAPI
前面CoreApi的介绍部分基本涵盖了ASMCore包下面的主要API及功能,其中还有一部分关于MetaData的解析和生成就不再赘述。这篇开始介绍ASM另一部分主要的Api。TreeApi。这一部分源码是关联的asm-tree-5.0.4的版本。
在介绍前,先要知道一点, Tree工程的接口基本可以完
- 链表树——复合数据结构应用实例
bardo
数据结构树型结构表结构设计链表菜单排序
我们清楚:数据库设计中,表结构设计的好坏,直接影响程序的复杂度。所以,本文就无限级分类(目录)树与链表的复合在表设计中的应用进行探讨。当然,什么是树,什么是链表,这里不作介绍。有兴趣可以去看相关的教材。
需求简介:
经常遇到这样的需求,我们希望能将保存在数据库中的树结构能够按确定的顺序读出来。比如,多级菜单、组织结构、商品分类。更具体的,我们希望某个二级菜单在这一级别中就是第一个。虽然它是最后
- 为啥要用位运算代替取模呢
chenchao051
位运算哈希汇编
在hash中查找key的时候,经常会发现用&取代%,先看两段代码吧,
JDK6中的HashMap中的indexFor方法:
/**
* Returns index for hash code h.
*/
static int indexFor(int h, int length) {
- 最近的情况
麦田的设计者
生活感悟计划软考想
今天是2015年4月27号
整理一下最近的思绪以及要完成的任务
1、最近在驾校科目二练车,每周四天,练三周。其实做什么都要用心,追求合理的途径解决。为
- PHP去掉字符串中最后一个字符的方法
IT独行者
PHP字符串
今天在PHP项目开发中遇到一个需求,去掉字符串中的最后一个字符 原字符串1,2,3,4,5,6, 去掉最后一个字符",",最终结果为1,2,3,4,5,6 代码如下:
$str = "1,2,3,4,5,6,";
$newstr = substr($str,0,strlen($str)-1);
echo $newstr;
- hadoop在linux上单机安装过程
_wy_
linuxhadoop
1、安装JDK
jdk版本最好是1.6以上,可以使用执行命令java -version查看当前JAVA版本号,如果报命令不存在或版本比较低,则需要安装一个高版本的JDK,并在/etc/profile的文件末尾,根据本机JDK实际的安装位置加上以下几行:
export JAVA_HOME=/usr/java/jdk1.7.0_25  
- JAVA进阶----分布式事务的一种简单处理方法
无量
多系统交互分布式事务
每个方法都是原子操作:
提供第三方服务的系统,要同时提供执行方法和对应的回滚方法
A系统调用B,C,D系统完成分布式事务
=========执行开始========
A.aa();
try {
B.bb();
} catch(Exception e) {
A.rollbackAa();
}
try {
C.cc();
} catch(Excep
- 安墨移动广 告:移动DSP厚积薄发 引领未来广 告业发展命脉
矮蛋蛋
hadoop互联网
“谁掌握了强大的DSP技术,谁将引领未来的广 告行业发展命脉。”2014年,移动广 告行业的热点非移动DSP莫属。各个圈子都在纷纷谈论,认为移动DSP是行业突破点,一时间许多移动广 告联盟风起云涌,竞相推出专属移动DSP产品。
到底什么是移动DSP呢?
DSP(Demand-SidePlatform),就是需求方平台,为解决广 告主投放的各种需求,真正实现人群定位的精准广
- myelipse设置
alafqq
IP
在一个项目的完整的生命周期中,其维护费用,往往是其开发费用的数倍。因此项目的可维护性、可复用性是衡量一个项目好坏的关键。而注释则是可维护性中必不可少的一环。
注释模板导入步骤
安装方法:
打开eclipse/myeclipse
选择 window-->Preferences-->JAVA-->Code-->Code
- java数组
百合不是茶
java数组
java数组的 声明 创建 初始化; java支持C语言
数组中的每个数都有唯一的一个下标
一维数组的定义 声明: int[] a = new int[3];声明数组中有三个数int[3]
int[] a 中有三个数,下标从0开始,可以同过for来遍历数组中的数
- javascript读取表单数据
bijian1013
JavaScript
利用javascript读取表单数据,可以利用以下三种方法获取:
1、通过表单ID属性:var a = document.getElementByIdx_x_x("id");
2、通过表单名称属性:var b = document.getElementsByName("name");
3、直接通过表单名字获取:var c = form.content.
- 探索JUnit4扩展:使用Theory
bijian1013
javaJUnitTheory
理论机制(Theory)
一.为什么要引用理论机制(Theory)
当今软件开发中,测试驱动开发(TDD — Test-driven development)越发流行。为什么 TDD 会如此流行呢?因为它确实拥有很多优点,它允许开发人员通过简单的例子来指定和表明他们代码的行为意图。
TDD 的优点:
&nb
- [Spring Data Mongo一]Spring Mongo Template操作MongoDB
bit1129
template
什么是Spring Data Mongo
Spring Data MongoDB项目对访问MongoDB的Java客户端API进行了封装,这种封装类似于Spring封装Hibernate和JDBC而提供的HibernateTemplate和JDBCTemplate,主要能力包括
1. 封装客户端跟MongoDB的链接管理
2. 文档-对象映射,通过注解:@Document(collectio
- 【Kafka八】Zookeeper上关于Kafka的配置信息
bit1129
zookeeper
问题:
1. Kafka的哪些信息记录在Zookeeper中 2. Consumer Group消费的每个Partition的Offset信息存放在什么位置
3. Topic的每个Partition存放在哪个Broker上的信息存放在哪里
4. Producer跟Zookeeper究竟有没有关系?没有关系!!!
//consumers、config、brokers、cont
- java OOM内存异常的四种类型及异常与解决方案
ronin47
java OOM 内存异常
OOM异常的四种类型:
一: StackOverflowError :通常因为递归函数引起(死递归,递归太深)。-Xss 128k 一般够用。
二: out Of memory: PermGen Space:通常是动态类大多,比如web 服务器自动更新部署时引起。-Xmx
- java-实现链表反转-递归和非递归实现
bylijinnan
java
20120422更新:
对链表中部分节点进行反转操作,这些节点相隔k个:
0->1->2->3->4->5->6->7->8->9
k=2
8->1->6->3->4->5->2->7->0->9
注意1 3 5 7 9 位置是不变的。
解法:
将链表拆成两部分:
a.0-&
- Netty源码学习-DelimiterBasedFrameDecoder
bylijinnan
javanetty
看DelimiterBasedFrameDecoder的API,有举例:
接收到的ChannelBuffer如下:
+--------------+
| ABC\nDEF\r\n |
+--------------+
经过DelimiterBasedFrameDecoder(Delimiters.lineDelimiter())之后,得到:
+-----+----
- linux的一些命令 -查看cc攻击-网口ip统计等
hotsunshine
linux
Linux判断CC攻击命令详解
2011年12月23日 ⁄ 安全 ⁄ 暂无评论
查看所有80端口的连接数
netstat -nat|grep -i '80'|wc -l
对连接的IP按连接数量进行排序
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
查看TCP连接状态
n
- Spring获取SessionFactory
ctrain
sessionFactory
String sql = "select sysdate from dual";
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
String[] names = wac.getBeanDefinitionNames();
for(int i=0; i&
- Hive几种导出数据方式
daizj
hive数据导出
Hive几种导出数据方式
1.拷贝文件
如果数据文件恰好是用户需要的格式,那么只需要拷贝文件或文件夹就可以。
hadoop fs –cp source_path target_path
2.导出到本地文件系统
--不能使用insert into local directory来导出数据,会报错
--只能使用
- 编程之美
dcj3sjt126com
编程PHP重构
我个人的 PHP 编程经验中,递归调用常常与静态变量使用。静态变量的含义可以参考 PHP 手册。希望下面的代码,会更有利于对递归以及静态变量的理解
header("Content-type: text/plain");
function static_function () {
static $i = 0;
if ($i++ < 1
- Android保存用户名和密码
dcj3sjt126com
android
转自:http://www.2cto.com/kf/201401/272336.html
我们不管在开发一个项目或者使用别人的项目,都有用户登录功能,为了让用户的体验效果更好,我们通常会做一个功能,叫做保存用户,这样做的目地就是为了让用户下一次再使用该程序不会重新输入用户名和密码,这里我使用3种方式来存储用户名和密码
1、通过普通 的txt文本存储
2、通过properties属性文件进行存
- Oracle 复习笔记之同义词
eksliang
Oracle 同义词Oracle synonym
转载请出自出处:http://eksliang.iteye.com/blog/2098861
1.什么是同义词
同义词是现有模式对象的一个别名。
概念性的东西,什么是模式呢?创建一个用户,就相应的创建了 一个模式。模式是指数据库对象,是对用户所创建的数据对象的总称。模式对象包括表、视图、索引、同义词、序列、过
- Ajax案例
gongmeitao
Ajaxjsp
数据库采用Sql Server2005
项目名称为:Ajax_Demo
1.com.demo.conn包
package com.demo.conn;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;
//获取数据库连接的类public class DBConnec
- ASP.NET中Request.RawUrl、Request.Url的区别
hvt
.netWebC#asp.nethovertree
如果访问的地址是:http://h.keleyi.com/guestbook/addmessage.aspx?key=hovertree%3C&n=myslider#zonemenu那么Request.Url.ToString() 的值是:http://h.keleyi.com/guestbook/addmessage.aspx?key=hovertree<&
- SVG 教程 (七)SVG 实例,SVG 参考手册
天梯梦
svg
SVG 实例 在线实例
下面的例子是把SVG代码直接嵌入到HTML代码中。
谷歌Chrome,火狐,Internet Explorer9,和Safari都支持。
注意:下面的例子将不会在Opera运行,即使Opera支持SVG - 它也不支持SVG在HTML代码中直接使用。 SVG 实例
SVG基本形状
一个圆
矩形
不透明矩形
一个矩形不透明2
一个带圆角矩
- 事务管理
luyulong
javaspring编程事务
事物管理
spring事物的好处
为不同的事物API提供了一致的编程模型
支持声明式事务管理
提供比大多数事务API更简单更易于使用的编程式事务管理API
整合spring的各种数据访问抽象
TransactionDefinition
定义了事务策略
int getIsolationLevel()得到当前事务的隔离级别
READ_COMMITTED
- 基础数据结构和算法十一:Red-black binary search tree
sunwinner
AlgorithmRed-black
The insertion algorithm for 2-3 trees just described is not difficult to understand; now, we will see that it is also not difficult to implement. We will consider a simple representation known
- centos同步时间
stunizhengjia
linux集群同步时间
做了集群,时间的同步就显得非常必要了。 以下是查到的如何做时间同步。 在CentOS 5不再区分客户端和服务器,只要配置了NTP,它就会提供NTP服务。 1)确认已经ntp程序包: # yum install ntp 2)配置时间源(默认就行,不需要修改) # vi /etc/ntp.conf server pool.ntp.o
- ITeye 9月技术图书有奖试读获奖名单公布
ITeye管理员
ITeye
ITeye携手博文视点举办的9月技术图书有奖试读活动已圆满结束,非常感谢广大用户对本次活动的关注与参与。 9月试读活动回顾:http://webmaster.iteye.com/blog/2118112本次技术图书试读活动的优秀奖获奖名单及相应作品如下(优秀文章有很多,但名额有限,没获奖并不代表不优秀):
《NFC:Arduino、Andro