这是我的代码:
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
返回以字节为单位的大小。问题是如果文件大小为 213.562 字节,则此属性返回 213562,返回大小中没有点 (.)。请给我返回确切大小的代码。