Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hi experts

How to know Image memory size in c# code.. please help me.


Thanks in Advance
Posted
Comments
ZurdoDev 5-Sep-14 7:23am    
Where are you stuck? Have you even tried anything?
NaniCh 5-Sep-14 7:32am    
Yes.. i converted images in bytes format.. but as per my requirement we don't allow images more than 100KB.. how to check this condition in c# code.?
vr reddy 5-Sep-14 7:41am    
FileInfo fileInfo = new FileInfo(Server.MapPath("~/Images/logo.gif"));
double fileSizeKB = fileInfo.Length / 1024;
if (fileSizeKB <= 100)
{ //your code
}
else { //skip
}
double fileSizeMB = fileInfo.Length / (1024 * 1024);

C#
FileInfo fileInfo = new FileInfo(Server.MapPath("~/Images/logo.gif"));
double fileSizeKB = fileInfo.Length / 1024;
double fileSizeMB = fileInfo.Length / (1024 * 1024);


[Edit member="Tadit"]
Added pre tags.
[/Edit]
 
Share this answer
 
v2
C# get memory size[^]


[Edit member="Tadit"]
Link text added to reflect the Article/QA title.
[/Edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900