asp.net 选择文件保存路径该怎么实现??????
我下面的备份代码该怎么改进才能实现保存路径的选择呢???
protected void btnBackUp_Click(object sender, EventArgs e) { string ConnctionString = "Data Source=.;User ID=sa;Password=123;Database='" + this.dbName.SelectedValue + "'"; string dbbackupfilepath = Server.MapPath("~/DBBackUpFile/DataBase"); string strSQL = "backup database " + this.dbName.SelectedValue + " to disk='" + dbbackupfilepath + "\\" + this.tbPosition.Text.Trim() + ".bak'"; try { //判断该路径下是否已经有该文件了 if (File.Exists(dbbackupfilepath + "\\" + this.tbPosition.Text.Trim() + ".bak")) { //存在此文件,提示错误 ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('文件名已存在,请重新命名!');</script>"); return; } else { using (SqlConnection con = new SqlConnection(ConnctionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand(strSQL, con)) { cmd.ExecuteNonQuery(); ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('数据库备份成功!');</script>"); } } } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('备份数据库失败!原因是:" + ex.Message + "');</script>"); } }
{
if (OpenFileDialog1.FileName.Length != 0)
{
if (Convert.ToInt32(strsNO) == 1)
{
strfile1 = OpenFileDialog1.FileName;
OpenFileDialog1.AddExtension = true;
strname1 = Path.GetFileName(strfile1);
dataProduct.Rows[dataProduct.CurrentRow.Index].Cells["附件"].Value = strname1;
txtMater.Focus();
}
else
{
strfile2 = OpenFileDialog1.FileName;
OpenFileDialog1.AddExtension = true;
strname2 = Path.GetFileName(strfile2);
dataProduct.Rows[dataProduct.CurrentRow.Index].Cells["附件"].Value = strname2;
txtMater.Focus();
}
}
}
}
}
}
[解决办法]
是web的???那就用webservice吧.