cant open file :(

reinstalled OS, but now cannot open file

Page 1 of 1

13 Replies - 982 Views - Last Post: 04 December 2009 - 02:04 PM Rate Topic: -----

#1 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

cant open file :(

Posted 04 December 2009 - 10:41 AM

So i reinstalled windows XP and installed VS 2008 and QT. Everything compiles and works but i cannot open a dang file. I have no idea why? Both QT and Visual Studio wont open a file


ifstream in("C:\\file.test");
if(in.is_open())
   cout<<"OPEN"<<endl;



can anyone thing of why this doesnt open a file, I wonder if something went wrong when reinstalling the OS

Is This A Good Question/Topic? 0
  • +

Replies To: cant open file :(

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: cant open file :(

Posted 04 December 2009 - 10:43 AM

Are you given an error message/dialog box about opening the file?
Was This Post Helpful? 0
  • +
  • -

#3 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 11:02 AM

Nope, it just does not open the file. Using the full path doesnt help either. Im so confused
Was This Post Helpful? 0
  • +
  • -

#4 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: cant open file :(

Posted 04 December 2009 - 11:04 AM

Run this with your file, does it execute the else part?

// ifstream::is_open
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  ifstream infile;
  infile.open ("test.txt");
  if (infile.is_open())
  {
	while (infile.good())
	  cout << (char) infile.get();
	infile.close();
  }
  else
  {
	cout << "Error opening file";
  }
  return 0;
}


Was This Post Helpful? 0
  • +
  • -

#5 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 11:17 AM

It executes the else fine, i created a file named test within the directory and it will not open
Was This Post Helpful? 0
  • +
  • -

#6 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: cant open file :(

Posted 04 December 2009 - 11:22 AM

Maybe it's a permissions issue?
Was This Post Helpful? 0
  • +
  • -

#7 GenHornet18  Icon User is offline

  • Darken the Radar

Reputation: 36
  • View blog
  • Posts: 629
  • Joined: 19-October 09

Re: cant open file :(

Posted 04 December 2009 - 11:26 AM

What's in the file? VirusScanner etc. may be interfering if it's deemed harmful.
Was This Post Helpful? 0
  • +
  • -

#8 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 11:28 AM

its a text file. im just trying to open any file
Was This Post Helpful? 0
  • +
  • -

#9 GenHornet18  Icon User is offline

  • Darken the Radar

Reputation: 36
  • View blog
  • Posts: 629
  • Joined: 19-October 09

Re: cant open file :(

Posted 04 December 2009 - 11:42 AM

It's not this test file is it?

your code looks fine, so post the *txt file.
Was This Post Helpful? 0
  • +
  • -

#10 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 01:43 PM

i meant to write test.txt - the code nor the file are the problem, its something that is either wrong with the restalation of the OS or the compiler( i doubt the compiler is the problem because QT doesnt open the file either)
Was This Post Helpful? 0
  • +
  • -

#11 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: cant open file :(

Posted 04 December 2009 - 01:46 PM

Do you have access like KYA suggested?

Administrative Privileges?
Was This Post Helpful? 0
  • +
  • -

#12 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 01:53 PM

I dont understand how the permisions would inhibit my access for just opening a file. Im gonna reinsal everything because i have nothing to do, but ill let you guys know what happens
Was This Post Helpful? 0
  • +
  • -

#13 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: cant open file :(

Posted 04 December 2009 - 01:58 PM

Do VS before a reformat. Windows possibly screwing up C++ opening a text file is just weird.
Was This Post Helpful? 0
  • +
  • -

#14 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,556
  • Joined: 09-June 09

Re: cant open file :(

Posted 04 December 2009 - 02:04 PM

very strange, but i rushed through the installation and didnt low level format the drive from the previous OS so im just gonna start from scratch, and if it does not work after then i have a serious problem, thanks KYA
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1