これは私のコードです:
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 を返すことです。戻りサイズにドット (.) がありません。正確なサイズを返すコードを教えてください。