473,382 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Error Opening multiple files

BB
Im trying to write a piece of code to open all files in the current
directory, read their contents and write it out to another file.
However after the program runs the output files are not there. Through
debugging I know the (output)files are being opened and the info. is being
wrote to them. But there is no files anywhere when the program finishes??
A piece of code used:

while( _findnext( hSearch, &FileData ) == 0 )
{
cout<<"FILE "<<FileData.name;
wFileIn.clear();

wFileIn.open(FileData.name,ios::in||ios::binary);
if(!wFileIn.is_open())
{
cout<<"File "<<FileData.name<<" could not be opened"<<endl;

}
else
{

getOutputFile(FileData.name,wOut);//gets the name of output file
wFileOut.clear();
wFileOut.open(wOut,ios::in||ios::out||ios::binary) ;

//read in data
//...

for(int i = 0;i < 27;i++)
wFileOut<<i;
wFileIn.close();
wFileOut.close();
}
}
_findclose( hSearch );
exit(0);

Thanks
Jul 22 '05 #1
2 1977
On Sat, 20 Dec 2003 15:56:04 -0000 in comp.lang.c++, "BB"
<ma******@eircom.net> was alleged to have written:
wFileIn.open(FileData.name,ios::in||ios::binary);
if(!wFileIn.is_open())
{
cout<<"File "<<FileData.name<<" could not be opened"<<endl;
if (!wFileIn)
perror(Filedata.name);
getOutputFile(FileData.name,wOut);//gets the name of output file
wFileOut.clear();
wFileOut.open(wOut,ios::in||ios::out||ios::binary) ;


if (!wFileOut)
perror(wOut);

Jul 22 '05 #2
On Sat, 20 Dec 2003 17:31:43 GMT in comp.lang.c++, David Harmon
<so****@netcom.com> was alleged to have written:
On Sat, 20 Dec 2003 15:56:04 -0000 in comp.lang.c++, "BB"
<ma******@eircom.net> was alleged to have written:
wFileIn.open(FileData.name,ios::in||ios::binary);


Oops, did not spot that the first time through!
Should be:
wFileIn.open(FileData.name, ios::in|ios::binary);

Use | for or-ing bits and flags.
Use || for or-ing true false bools;
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: mattsniderppl | last post by:
Hi, i'm relatively new to C++ from java and am having a difficult time with pointers. I'm sure there is something simple that I am doing wrong, but I can't seem to write this in a way that doesn't...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
2
by: SenthilVel | last post by:
HI all in my visual studio DOtnet . i am not able to open multiple cs files in the projects , its openings only one cs file at a time, can any one let me know, what setttings i must do in order...
0
by: vinX | last post by:
Ok, i am making a file renaming utility, you can add filesize (in MB o KB), filepath, creation date and/or time, a counter, parent folder, th original name etc... I put the program in the...
9
by: JTrigger | last post by:
When I compile my project using the IDE on a development machine it works just fine. When I compile it on the server using csc.exe, I get the following error when I try to bring it up in the web...
1
by: abh1508 | last post by:
Following a release of code the following problem occurs on certain asp ..net pages. This is not a problem on other testing/demo environments. IIS seems to be creating certain files twice in the...
3
emaghero
by: emaghero | last post by:
Hello all, I want to open multiple txt files with similar names in C++ I have attempted this with the following code //Create as many txt files as there are valid propagation constants...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.