易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET在本地服务器上创建目录并在该目录下写文件

public static Boolean WriteTextFile(string content, string filepath,string name)
{
FileStream fs;
StreamWriter sw;
if (!System.IO.Directory.Exists(filepath))
{
DirectoryInfo DirInfo = Directory.CreateDirectory(filepath); //创建目录
DirInfo.Attributes = FileAttributes.Normal;
}
string fullpath = filepath + name + ".txt";
if (File.Exists(fullpath))//验证文件是否存在
{
return false;
}
else
{
fs = new FileStream(fullpath, FileMode.Create, FileAccess.Write);
sw = new StreamWriter(fs,System.Text.Encoding.Default);
sw.WriteLine(content);
sw.Close();
fs.Close();
return true;
}
}
 在做这个相关工作的时候 还碰到一个问题就是 用一下方法读取中文文本文件时,出现乱码的现象:
public static String ReadTextFile(string filepath)
{
StreamReader objReader = new StreamReader(filepath);
string sLine = "";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();
StringBuilder sb = new StringBuilder();
foreach (string sOutput in arrText)
sb.Append(sOutput);
return sb.ToString();
}
查询资料 发现对上面代码中的StreamReader修改一下,如下代码:
public static String ReadTextFile(string filepath)
{
StreamReader objReader = new StreamReader(filepath, System.Text.Encoding.Default);
string sLine = "";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();
S


相关文档:

图片文件上传, 生成高质量缩略图 (asp.net c#)

后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Dat ......

ASP.net

C#:成员变量首字母大写而且前面加下划线
   1.连接对象静态与非静态问题
   2.数据访问类为什么不能派生与DBConnection
   3.Catch的作用,以及为什么可以在这里省掉
   4.在数据访问方法中,为什么不直接实例化     List<NationData> list;
  ......

Asp.net 使用 AXAJ局部刷新无效的解决方法

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<!--
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0 ......

Asp.NET生成静态页面并分页(文章内容分页)

主要的原理就是替换模板里的特殊字符。
1、静态模板页面 template.html,主要是定义了一些特殊字符,用来被替换。
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">   <html>   <he ......

ASP.NET防止重复提交的Javascript脚本

function _doPostBack(){};
if(typeof("__doPostBack")=="function")
{
_doPostBack=__doPostBack;
__doPostBack=_doPostBackNew;
}
document.attachEvent("onmousemove",_onmousemove);
var _isPosting=false;
var _divMask=null;
function _onmousemove()
{
if(_divMask)
with(_divMask.runtimeStyle)
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号