一、IndexOf如果不区分大小写
string s="AVI";
int naavi=body.ToLower().IndexOf(s.ToLower(),0);
二、上传大于4M的文件 修改web.config
<system.web>
<httpRuntime executionTimeout="600" maxRequestLength="51200" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/>
</system.web>
三、文件下载函数
#region 下载文件
public static void DownFile(string filePath,string fileName)
{
FileInfo fileInfo = new FileInfo(filePath);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
//HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename=" + fileName);
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8));
HttpContext.Current.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding","binary");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
HttpContext.Current.Response.WriteFile(fileInfo.FullName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
#endregion
四、无法验证资料错误解决办法。
只要在 Web.config 中的<system.web> </system.web> 節點里加入以下字串即能解決
<pages enableViewStateMac="false"/>
或是把它放在頁面開頭
<%@ Page language="c#" enableViewStateMac="false" %>
转载于:https://www.cnblogs.com/xunt/archive/2005/12/29/307587.html