protected void Btn_Up_Click(object sender, EventArgs e)
{
// Specify the path on the server to
// save the uploaded file to.
// String savePath = @"D:/WebSite/FileUpload/UploadedImages/";
String savePath = @"\\192.168.1.188\temp\00-T1\";
// Before attempting to perform operations
// on the file, verify that the FileUpload
// control contains a file.
if (FileUpload1.HasFile)
{
// Get the name of the file to upload.
String fileName = FileUpload1.FileName;
// Append the name of the file to upload to the path.
savePath += fileName;
// Call the SaveAs method to save the
// uploaded file to the specified path.
// This example does not perform all
// the necessary error checking.
// If a file with the same name
// already exists in the specified path,
// the uploaded file overwrites it.
FileUpload1.SaveAs(savePath);
// Notify the user of the name of the file
// was saved under.
//UploadStatusLabel.Text = "Your file was saved as " + fileName;
//Response.Write("<script>alert(‘你的文件保存在 ‘" + fileName + "‘!‘)</script>");
this.Label1.Text = "你的文件保存在 ‘" + savePath + "‘!";
}
else
{
// Notify the user that a file was not uploaded.
//UploadStatusLabel.Text = "You did not specify a file to upload.";
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert(‘你没有指定文件名上传 ‘);", true);
}
}
protected void Btn_Open_Click(object sender, EventArgs e)
{
try
{
System.Diagnostics.Process.Start(@"\\192.168.1.188\temp\00-T1\2.xlsx");
}
catch (Exception ex)
{
//Response.Write("<script language=‘javascript‘>alert(‘" + ex.Message.ToString() + "‘);</script>");
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert(‘" + ex.Message.ToString() + "‘);", true);
}
}
protected void Btn_Clearn_Click(object sender, EventArgs e)
{
//获得图片的服务器路径
//string delFile = Server.MapPath("~/photo/img1.JPG");
string delFile [email protected]"\\192.168.1.188\temp\00-T1\1.xlsx";
//删除图片
File.Delete(delFile);
}
//*****************************************
<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="显示:" Width="409px"></asp:Label>
<br />
<br />
<asp:Button ID="Btn_Up" runat="server" onclick="Btn_Up_Click"
Text="Up_test" Width="76px" />
<asp:Button ID="Btn_Clearn" runat="server" onclick="Btn_Clearn_Click"
Text="Clearn" style="height: 26px" Width="77px" />
<br />
<asp:Button ID="Btn_Open" runat="server" onclick="Btn_Open_Click" Text="Open"
Width="76px" />
<br />
<br />
//*****************************************