private void button1_click(object sender, system.eventargs e)
{//新建文件
string path=server.mappath("index4.aspx");
//response.write(datetime.now.tostring("yyyymmdd"));
//获得文件名
int filelen=path.lastindexof(".");
int pathlen=path.length;
string tempname=path.substring(filelen,pathlen-filelen);
//获取文件路径
int len=path.lastindexof(@"/");
string temppath=path.substring(0,len)+"//"+datetime.now.tostring("yyyymmddhhssmm")+tempname;
try
{
file.create(temppath);
response.write("<script>alert('新建文件成功');</script>");
}
catch(exception ex)
{
response.write(ex.tostring());
}
}
private void button2_click(object sender, system.eventargs e)
{//复制文件
string path=server.mappath("index4.aspx");
//response.write(datetime.now.tostring("yyyymmdd"));
//获得文件名
int filelen=path.lastindexof(".");
int pathlen=path.length;
string tempname=path.substring(filelen,pathlen-filelen);
//获取文件路径
int len=path.lastindexof(@"/");
string temppath=path.substring(0,len)+"//"+datetime.now.tostring("yyyymmddhhssmm")+tempname;
try
{
file.copy(path,temppath);
response.write("<script>alert('复制文件成功');</script>");
}
catch(exception ex)
{
response.write(ex.tostring());
}
}
private void button3_click(object sender, system.eventargs e)
{//删除文件
string path=server.mappath("index4.aspx");
//response.write(datetime.now.tostring("yyyymmdd"));
//获得文件名
int filelen=path.lastindexof(".");
int pathlen=path.length;
string tempname=path.substring(filelen,pathlen-filelen);
//获取文件路径
int len=path.lastindexof(@"/");
//string temppath=path.substring(0,len)+"//"+datetime.now.tostring("yyyymmddhhssmm")+tempname;
string temppath=path.substring(0,len)+"//"+"20063702021337.aspx";
try
{
file.delete(temppath);
response.write("<script>alert('删除文件成功');</script>");
}
catch(exception ex)
{
response.write(ex.tostring());
}
}
新闻热点
疑难解答
图片精选