温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:BugNet0.7.881.0汉化免安装版源码
当前文件路径:BugNet/BugNET_WAP/Bugs/ViewAttachment.aspx.cs

1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.IO; 6
using System.Text; 7
using System.Drawing; 8
using System.Web; 9
using System.Web.SessionState; 10
using System.Web.UI; 11
using System.Web.UI.WebControls; 12
using System.Web.UI.HtmlControls; 13
using System.Configuration; 14
using BugNET.BusinessLogicLayer; 15
16
namespace BugNET 17
{ 18
/// <summary> 19
/// Summary description for ViewAttachment. 20
/// </summary> 21
public partial class ViewAttachment : System.Web.UI.Page 22
{ 23
protected int BugAttachmentID; 24
25
/// <summary> 26
/// Handles the Load event of the Page control. 27
/// </summary> 28
/// <param name="sender">The source of the event.</param> 29
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> 30
protected void Page_Load(object sender, System.EventArgs e) 31
{ 32
33
BugAttachmentID = Convert.ToInt32(Request.Params["aid"]); 34
35
if (BugAttachmentID != 0) 36
{ 37
38
Attachment att = Attachment.GetAttachmentById(BugAttachmentID); 39
Bug b = Bug.GetBugById(att.BugId); 40
Project p = Project.GetProjectById(b.ProjectId); 41
42
string FileName = att.FileName; 43
string ProjectPath = p.UploadPath; 44
string Path; 45
46
//append a trailing slash if it doesn't exist 47
if(!ProjectPath.EndsWith("\\")) 48
ProjectPath = String.Concat(ProjectPath,"\\"); 49
50
Path = String.Concat("~\\Uploads\\", ProjectPath, FileName); 51
52
if (System.IO.File.Exists(Server.MapPath(Path))) 53
{ 54
Response.Clear(); 55
Response.ContentType = att.ContentType; 56
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName); 57
Response.WriteFile(Path); 58
} 59
else 60
{ 61
Response.Write("<h1>Attachment Not Found.</h1> It may have been deleted from the server."); 62
} 63
} 64
65
} 66
67
Web Form Designer generated code 89
} 90
} 91





}