Get file size
-
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
-
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
-
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
Are you kidding?? If not, my suggestion would be: Go back to first grade and start all over again.
-
No, that would be a Kibibyte.
-
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
Do you know
bytes
andkilobytes
are simply related, don't you? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
Do you really need to open the file and seek to end to get the size? Why directory informations are for then??
Maruf Maniruzzaman @ Dhaka, Bangladesh. [Homepage] [Blog] [Silverlight Clone] [Resume]
-
I am reading the value of the size from the properties file... e.g. file_size=500. I have to check for the file size limit. The max limit is set as done above. During runtime the following function checks for the file size with the above by using the following function to get the current file size.
int get_file_size()
{
long file_size;
ifstream myfile;
myfile.open(path.c_str());
myfile.seekg(0, ios::end);
file_size = myfile.tellg();
myfile.close();
return file_size;
}But if I do this I get the file size in bytes. I want to do everything in kb's. Any suggestion please. THANKS.
Why you dont use of
CFile::GetLength
orGetFileAttributesEx
if you dont like to use of them so I tell you a secret that is on the c++ and its:StrFormatByteSizeA
. :laugh: -
Do you know
bytes
andkilobytes
are simply related, don't you? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
kilobytes
Kilo is actually metric and means 1000, not 1024. ;P
-
CPallini wrote:
kilobytes
Kilo is actually metric and means 1000, not 1024. ;P
I know but: (1) It is a controversial point [^](do you manufacture hard disks?). (2) It has no releveance on my statement validity. ;P :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I know but: (1) It is a controversial point [^](do you manufacture hard disks?). (2) It has no releveance on my statement validity. ;P :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeI was just stating how I interpret the term "kilo", not how the HD manufacturers abuse it for their marketing. Interesting article on Wikipedia, by the way. I think these new IEC (kibi, mebi :omg: ) and Jedec standards are just idiotic. They should simply stick with KB/KByte, MB/MByte.