User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 363,800 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,557 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:

Check the size of a file

Join Date: Feb 2008
Posts: 412
Reputation: Jennifer84 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Jennifer84 Jennifer84 is online now Online
Posting Pro in Training

Re: Check the size of a file

  #3  
May 9th, 2008
I understand. This is the first time I am trying to do something like this.
I have rewritten this code a little bit as I am writing this for a buttonControl.
I have taken if(infile.is_open()) away as seen because when having this I received the size of: 0. I am not sure if this was okay to do ?

My file is 230 kb.
The messageBox will show this numer: 4294967295
Have I missed something ?

size_t fileSize = 0;
string path = string path = "C:\\Folder1\\Folder2\\OneFile.txt";

ifstream infile(path.c_str());

//if(infile.is_open())
//{
         infile.seekg(0, ios::end); //move to end of file
         fileSize = infile.tellg();
//}
			
	stringstream Getsize;
	std::string Getsize2;
	Getsize << fileSize;
	Getsize2 = Getsize.str();
					 
	String^ sizeee = gcnew String(Getsize2.c_str());
	MessageBox::Show(sizeee);
Last edited by Jennifer84 : May 9th, 2008 at 6:42 pm.
Reply With Quote  
All times are GMT -4. The time now is 11:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC