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)+"http://"+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)+"http://"+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)+"http://"+datetime.now.tostring("yyyymmddhhssmm")+tempname;
string temppath=path.substring(0,len)+"http://"+"20063702021337.aspx";
try
{
file.delete(temppath);
response.write("<script>alert('刪除文件成功');</script>");
}
catch(exception ex)
{
response.write(ex.tostring());
}
}
新聞熱點
疑難解答
圖片精選