473,467 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Remove and Rename using fstream

Hi All,

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


Jul 22 '05 #1
3 5732
"Venkat" <ve*******@yahoo.com> 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.


Jul 22 '05 #2
Venkat wrote:
"Venkat" <ve*******@yahoo.com> 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
Jul 22 '05 #3
Venkat wrote in news:1073545086.672037@sj-nntpcache-5:
"Venkat" <ve*******@yahoo.com> 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/
Jul 22 '05 #4

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

Similar topics

3
by: Wm | last post by:
I have a table of users in mySQL that appears to have a lot of duplicates. What's the best way to look at the userID and email and delete the duplicates? Thanx, Wm
4
by: Christopher Armstrong | last post by:
Hello! I'm trying to write a part of a program that will remove all files in its directory. I have tried the std::remove feature of the standard library, but I don't know its syntax. Also, what's...
8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
1
by: Matt | last post by:
Hello, I would like to be able to delete (as in stdio.h remove()) fstream objects. Is there a means for me to do this in C++? I see no such capability in my references. remove() is not so...
11
by: Dorsa | last post by:
HI, Could you please tell me the error in here. I am trying to open an XML file from a link. Response.Clear() Response.Expires = 0 Response.BufferOutput = False Response.ContentType =...
9
by: Someonekicked | last post by:
In my program, I need to open multiple files, and I wont know till after the program execution how many of them (user will enter that value). So I am using a vector of fstream. I am using fstream...
5
by: Russell Warren | last post by:
I've got a case where I'm seeing text files that are either all null characters, or are trailed with nulls due to interrupted file access resulting from an electrical power interruption on the...
6
by: topala1984 | last post by:
hello all excuse my english, I`m a beginer in java and I want to remove duplicate cities + rearrenging file`s lines elements from one 150 mb file, in my file I have that: ...
61
by: arnuld | last post by:
I have created a program which creates and renames files. I have described everything in comments. All I have is the cod-duplication. function like fopen, sprint and fwrite are being called again...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.