asp.net c# 数据库备份
protected void btnsearch_ServerClick(object sender, EventArgs e)
{
string lujing=this.Text2.Value.ToString().Trim();
string shujuku = this.jine.Value;
string wenjianming = this.Text1.Value.ToString().Trim();
if (wenjianming.IndexOf(".bak") == -1)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('备份文件名格式错误!');</script>");
return;
}
if (System.IO.File.Exists(lujing))
{
//则表示存在
}
else
{
//创建该文件夹
System.IO.Directory.CreateDirectory(lujing);
}
string wenjj = lujing + @"\" + wenjianming;
if (System.IO.File.Exists(wenjj))
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('备份文件名已存在,请重新命名!');</script>");
return;
}
string cmd1 = "backu
相关文档:
用c#给PDA做了一个PC端的通讯程序,需要保存两个参数。用Delphi时,是保存在ini文件中,c#读写XML比较方便,就用xml文件来保存了。
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// 下载到PDA的TXT文件路径
/// </summary>
......
using System;
using System.Data;
using System.Configuration;
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.IO;
public partial class _Default : Syste ......
Request.ServerVariables["Url"]
返回服务器地址
Request.ServerVariables["Path_Info"]
客户端提供的路径信息
Request.ServerVariables["Appl_Physical_Path"]
与应用程序元数据库路径相应的物理路径
Request.ServerVariables["Path_Translated"]
通过由虚拟至物理的映射后得到的路径
Request.ServerVariables ......
从来都很少写博,现在开始写写,方便自己用的时候不用搜索,或许还可以帮助到别人,何乐而不为呢?呵呵。
注意事项一:如果页面点击按钮无法触发验证控件的作用时,解决办法如下:
c:\WINNT\Microsoft.NET\Framework\v1.1.4322
1.开始菜单-->运行cmd
&nbs ......
程序启动Sql Server其实很简单
代码:
System.ServiceProcess.ServiceController myController =
new System.ServiceProcess.ServiceController("MSSQL$ACCP4444"); //服务名称 找了半天才找到,笨死我完了。在服务上右键属性,能看到
if (myController.CanStop)
{ }
else ......