我想使用Intent文件选择器选择文件,但条件是文件大小不应大于5 MB。有人可以在这方面帮助我如何限制文件大小吗?
var result = myDbContext.PurchaseProducts.GroupJoin(
myDbContext.ProductStocks,
purchaseProduct => purchaseProduct.Id, // from every PurchaseProduct take the Id
productStock => productStock.PurchaseProductId, // from every ProductStock take the foreign key
// ResultSelector: from every PurchaseProducts, with all its matching ProductStocks
// calculate A + B + Sum of all C of the productStocks
(purchaseProduct, productStocksOfThisPurchaseProduct) =>
purchaseProduct.A + purchaseProduct.B +
productStocksOfThisPurchaseProduct.Select(productStock => productStock.C).Sum());
答案 0 :(得分:0)
您可以做这样的事情
onActivity结果旁边
photoPath = data.getStringExtra("filepath");
File file_image = new File(photoPath);
int file_Size = Integer.parseInt(String.valueOf(file_image.length() / 1024));//bytes size
Log.e("FileByteSize", "Byte :" + file_Size);
int image_inMb = file_Size / 1024;
Log.e("FileByteSize", "MB :" + image_inMb);
if (image_inMb > 5)
{
Toast.makeText(getContext(), R.string.max_allowed_size_two_mb, Toast.LENGTH_LONG).show();
return;
}