Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Remove and Rename using fstream

Reply
Thread Tools

Remove and Rename using fstream

 
 
Venkat
Guest
Posts: n/a
 
      01-08-2004
Hi All,

Currently i guess rename and remove are not supported using fstream.
How do i rename or remove a file?


regards,
Venkat




 
Reply With Quote
 
 
 
 
Venkat
Guest
Posts: n/a
 
      01-08-2004
"Venkat" <(E-Mail Removed)> wrote in message
news:1073544519.907492@sj-nntpcache-5...
> Hi All,
>
> Currently i guess rename and remove are not supported using fstream.
> How do i rename or remove a file?
>
>
> regards,
> Venkat


Also to add, std::rename and std::remove are throwing compile errors
saying rename and remove are not members of std, even after including
<cstdio> library.




 
Reply With Quote
 
 
 
 
CrayzeeWulf
Guest
Posts: n/a
 
      01-08-2004
Venkat wrote:

> "Venkat" <(E-Mail Removed)> wrote in message
> news:1073544519.907492@sj-nntpcache-5...


>
> Also to add, std::rename and std::remove are throwing compile errors
> saying rename and remove are not members of std, even after including
> <cstdio> library.
>

Show us the code.

--
CrayzeeWulf
 
Reply With Quote
 
Rob Williscroft
Guest
Posts: n/a
 
      01-08-2004
Venkat wrote in news:1073545086.672037@sj-nntpcache-5:

> "Venkat" <(E-Mail Removed)> wrote in message
> news:1073544519.907492@sj-nntpcache-5...
> > Hi All,
> >
> > Currently i guess rename and remove are not supported using fstream.


These function's take arguments that are filenames and have type
char const *, they don't have anything to do with fstream's or
<stdio.h>'s FILE's.

> > How do i rename or remove a file?
> >


First close any open fstream's you have associated with the file,
then call

std::rename( "oldname", "newname" ); or
std::remove( "oldname" );

Replace "oldname"/"newname" with the appropriate literals or
char const *varaible, or use std::string's c_str() member:

std::string name = "filename";

std::ifstream ifs( name.c_str() );

// read something from ifs;

ifs.close();

std::remove( name.c_str() );


>
> Also to add, std::rename and std::remove are throwing compile errors
> saying rename and remove are not members of std, even after including
> <cstdio> library.
>


How are you calling them, whats the error and what compiler are you
using. Prefereably post some actual code (cut & paste) that doesn't
compile.

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Funky file contents when os.rename or os.remove are interrupted Russell Warren Python 5 10-11-2006 04:40 PM
reading from "unknown" number and names of files using fstream jccorreu@gmail.com C++ 7 05-02-2006 03:50 PM
exception woes using fstream and .eof Greg C++ 7 12-19-2005 07:41 PM
remove() capability in fstream class/templates? Matt C++ 1 02-14-2005 02:08 AM
what is different between <fstream.h> and <fstream>MS VC++ Armando C++ 6 01-29-2004 09:01 AM



Advertisments