This is my code:
if (btnfileupload.HasFile)
{
try
{
Int64 _size = 0;
string strsize = null;
int y = 0;
_size = btnfileupload.PostedFile.ContentLength;
strsize = _size.ToString();
if (strsize.Contains("."))
{
y = strsize.IndexOf(".");
strsize = strsize.Substring(0, y - 1);
}
Int64 _accountno = (Int64)Session["aco"];
home h = new home();
h._Account_number = _accountno;
h._FileName = Path.GetFileName(btnfileupload.FileName);
h._file_size = strsize;
h._uploadDate = DateTime.Now;
bool b = h.FileuploadSave(firstfilename);
if (b)
Response.Write("<script> aleart('File Uploaded') </script>");
Fillgrid(null, null);
}
catch (Exception)
{
}
}
btnfileupload.PostedFile.ContentLength
return the size in bytes. The problem is if file size is 213.562 bytes then this property returns 213562 there is no dot(.) in return size. Please give me code that returns exact size.