473,564 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ 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 5754
"Venkat" <ve*******@yaho o.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*******@yaho o.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*******@yaho o.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
7944
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
12696
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 the difference between std::remove and std::erase? Thanks for your time!
8
9834
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 | ios::binary) to declare a file object with read/write modes turned on for working with binary data. I've tried this and my file is not created. The only...
1
2374
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 bad, except for the fact that I need to keep track of a file's associated name in addition to it's fstream reference (I'm presuming that fstream can...
11
4027
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 = "text/xml" Response.AddHeader("Content-Disposition", "filename=test.XML")
9
5275
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 since I will need to write and read from files, and I am using those files as binary files. I made a sample of what's going on (below). Without...
5
1541
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 WinXP pc. In tracking it down, it seems that what is being interrupted is either os.remove(), or os.rename(). Has anyone seen this behaviour, or have...
6
10294
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: "68586240","68586367","IRVING" "68586368","68586431","DENTON" "68586432","68586495","DENTON" and I want to become
61
3229
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 and again. I know to remove code-duplication I have to make functions and pass arguments to them but I am not able to think of a way doing it....
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.