i am taking bytes array from file upload control and saving them in a class object but i am getting exception of stackoverflow infinite loop or recursive like sonmething.
my code is:
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;
}
}
here is my gridview button event where i am setting the objects value:
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"));
}
You’ve got an infinite recursion in your getter/setter.
Do you want to write it to
FileinBytes?An alternative could be to use an auto implemented property: