我正在从文件上传控件中获取字节数组并将它们保存在一个类对象中,但是我遇到了 stackoverflow 无限循环或递归之类的异常。
我的代码是:
public class UploadDetail
{`enter code here`
//public bool IsReady { get; set; }
public string FileSize { get; set; }
//public int UploadedLength { get; set; }
public string FileName { get; set; }
public byte[] FileinBytes;
public byte[] FileBytes
{
get
{
return FileBytes;
}
set
{
FileBytes = value;
}
}
这是我设置对象值的gridview按钮事件:
protected void gvUploadFiles_Clicked(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "doingUpload")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvUploadFiles.Rows[index];
if (gvUploadFiles.DataKeys[index]["FileName"] != null)
{
currentUpload.FileName = gvUploadFiles.DataKeys[index]["FileName"].ToString();
}
if (gvUploadFiles.DataKeys[index]["FileSize"] != null)
{
currentUpload.FileSize = gvUploadFiles.DataKeys[index]["FileSize"].ToString();
}
if (gvUploadFiles.DataKeys[index]["FileBytes"] == null)
{
currentUpload.FileBytes=(byte[])gvUploadFiles.DataKeys[index]["UploadDetail.FileBytes()"];
//currentUpload.FileBytes(row.FindControl("fileBytes"));
}