Click here to Skip to main content
15,905,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Random number generator Pin
Mike Dimmick31-Oct-03 6:14
Mike Dimmick31-Oct-03 6:14 
QuestionHow to create a slider control Pin
vhunghl30-Oct-03 14:07
vhunghl30-Oct-03 14:07 
AnswerRe: How to create a slider control Pin
vcplusplus30-Oct-03 14:16
vcplusplus30-Oct-03 14:16 
GeneralRe: How to create a slider control Pin
vhunghl30-Oct-03 22:44
vhunghl30-Oct-03 22:44 
Questionwhy does it not happen MM_WOM_DONE? Pin
vhunghl30-Oct-03 13:25
vhunghl30-Oct-03 13:25 
Questionhow to find whether a file already exists in a folder? Pin
Deepak Samuel30-Oct-03 12:53
Deepak Samuel30-Oct-03 12:53 
AnswerRe: how to find whether a file already exists in a folder? Pin
yndfcd30-Oct-03 13:17
yndfcd30-Oct-03 13:17 
AnswerRe: how to find whether a file already exists in a folder? Pin
Jeryth30-Oct-03 13:18
Jeryth30-Oct-03 13:18 
Open up "My Computer" and double-click the folders to the right directory...

I take it you're asking about file existance from an fstream point of view. If you're looking if "foo.txt" exists you can do something like the following:

ifstream fin( "foo.txt" );
if ( fin )
{
     //You get in here the file's already there
}
else
{
     //File's not created
}


You could also use the ios flags ios::nocreate and ios::noreplace with an ofstream object:

ofstream fout( "foo.txt" ios::noreplace )
if ( fout )
{
     //File didn't exist but it does now
}
else
{
     //File existed and your fout creation failed
}


||


ofstream fout( "foo.txt" ios::nocreate )
if ( fout )
{
     //File existed but it's about to get truncated
}
else
{
     //File doesn't exist and your fout creation failed
}


Hopefully that helped a little.


Always Fear the Man with Nothing to Lose

Jeryth
AnswerRe: how to find whether a file already exists in a folder? Pin
vcplusplus30-Oct-03 14:26
vcplusplus30-Oct-03 14:26 
GeneralOperator Overloading Troubles Pin
Jeryth30-Oct-03 12:48
Jeryth30-Oct-03 12:48 
GeneralRe: Operator Overloading Troubles Pin
ZoogieZork30-Oct-03 13:42
ZoogieZork30-Oct-03 13:42 
GeneralRe: Operator Overloading Troubles Pin
Jeryth30-Oct-03 14:11
Jeryth30-Oct-03 14:11 
GeneralRe: Operator Overloading Troubles Pin
ZoogieZork30-Oct-03 15:12
ZoogieZork30-Oct-03 15:12 
GeneralRe: Operator Overloading Troubles Pin
jason9931-Oct-03 2:00
jason9931-Oct-03 2:00 
GeneralRe: Operator Overloading Troubles Pin
Jeryth31-Oct-03 6:38
Jeryth31-Oct-03 6:38 
GeneralWindow focus problems Pin
paulb30-Oct-03 12:32
paulb30-Oct-03 12:32 
GeneralRe: Window focus problems Pin
Anthony_Yio30-Oct-03 15:33
Anthony_Yio30-Oct-03 15:33 
GeneralCTabCtrl and tooltips Pin
andyvinc30-Oct-03 9:15
andyvinc30-Oct-03 9:15 
GeneralRe: CTabCtrl and tooltips Pin
igor196030-Oct-03 9:40
igor196030-Oct-03 9:40 
Generaleditor Pin
TimWallace30-Oct-03 9:11
TimWallace30-Oct-03 9:11 
QuestionHow do you create .LIB files? Pin
mwhannan30-Oct-03 9:01
mwhannan30-Oct-03 9:01 
AnswerRe: How do you create .LIB files? Pin
Jörgen Sigvardsson30-Oct-03 9:22
Jörgen Sigvardsson30-Oct-03 9:22 
GeneralRe: How do you create .LIB files? Pin
mwhannan30-Oct-03 9:27
mwhannan30-Oct-03 9:27 
GeneralRe: How do you create .LIB files? Pin
Anthony_Yio30-Oct-03 15:35
Anthony_Yio30-Oct-03 15:35 
Generalservice DLL and application communication Pin
Kuniva30-Oct-03 8:47
Kuniva30-Oct-03 8:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.