Javascript:
public void DeleteImage_OnClick(object sender, EventArgs e) {
if (FileToDelete.Value != "" && FileToDelete.Value != "undefined") {
try {
string AppPath = HttpContext.Current.Request.PhysicalApplicationPath;
System.IO.File.Delete(AppPath + CurrentImagesFolder.Value + "\\" + FileToDelete.Value);
ResultsMessage.Text = "Deleted: " + FileToDelete.Value;
} catch(Exception ex) {
ResultsMessage.Text = "There was an error.";
}
} else {
ResultsMessage.Text = NoFileToDeleteMessage;
}
DisplayImages();
}
public void DeleteImage_OnClick(object sender, EventArgs e) {
if (FileToDelete.Value != "" && FileToDelete.Value != "undefined") {
try {
string AppPath = HttpContext.Current.Request.PhysicalApplicationPath;
System.IO.File.Delete(AppPath + CurrentImagesFolder.Value + "\\" + FileToDelete.Value);
ResultsMessage.Text = "Deleted: " + FileToDelete.Value;
} catch(Exception ex) {
ResultsMessage.Text = "There was an error.";
}
} else {
ResultsMessage.Text = NoFileToDeleteMessage;
}
DisplayImages();
}
解决方案 »
- 为什么会报“文本内容中发现无效字符。处理资源”错呢,我没有做什么。
- 图片上传,本机调试没有问题,上传到服务器就出问题
- 关于JMail组建在服务器上运行错误
- 关于mappath的图片显示的问题
- asp.net updatepanel 问题
- 一问题不得解
- System.Web.Security.FormsAuthentication.SetAuthCookie(userGet.UserName,false); 用户登录后一下子就为空了,请问如何设置它的有效时间
- # 与 = 有什么区别
- 请教:水晶报表小问题?
- 怎樣給DataSet中表t1第gbRow行的字段store_date(即gbRow.store_date)賦空值null?
- 命名空间问题!
- ListBox问题,高手请进!
{
string sqlstr="select pic from product where id=" +id.ToString();
OleDbConnection conn=new OleDbConnection(Application.Get("connstr").ToString());
conn.Open();
OleDbCommand cmd=new OleDbCommand(sqlstr,conn);
cmd.CommandType=CommandType.Text;
string picPath=((object)cmd.ExecuteScalar()).ToString();
if (picPath.Length!=0)
{
int i= picPath.LastIndexOf(@"\");
//取得文件名
string fileName =picPath.Substring(i); picPath=Application.Get("uploadpath").ToString()+fileName;
if(File.Exists(picPath))
{
File.Delete(picPath);
}
}
sqlstr="select smallpic from product where id="+id.ToString();
cmd.CommandText=sqlstr;
cmd.CommandType=CommandType.Text;
picPath=((object)cmd.ExecuteScalar()).ToString();
if (picPath.Length!=0)
{
int i= picPath.LastIndexOf(@"\");
//取得文件名
string fileName =picPath.Substring(i); picPath=Application.Get("uploadpath").ToString()+fileName;
if(File.Exists(picPath))
{
File.Delete(picPath);
}
}
conn.Close();
}