473,396 Members | 1,921 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,396 software developers and data experts.

fstream in non-current directory

Could you give some examples about how to write a file in a non local
directory?
And what if the directory is not exist, do I have to create one?

Thanks,
Peng
Jul 22 '05 #1
2 2057
Peng Yu wrote:
Could you give some examples about how to write a file in a non local
directory?
There is no concept of "directory" in C++. Whatever form you need to
give the file name to reach the "non-local directory" should work just
fine.
And what if the directory is not exist, do I have to create one?


That's OS-specific. For all C++ cares, opening a file that specifies
a name with a "directory" that "doesn't exist" might initiate some kind
of "creation of the directory" operation.

Try posting to a newsgroup that deals with your OS.

V
Jul 22 '05 #2
Peng Yu <pe*******@gmail.com> wrote in message news:<e2********************************@4ax.com>. ..
Could you give some examples about how to write a file in a non local
directory?
And what if the directory is not exist, do I have to create one?


Not possible in standard C++ yet, but boost has a filesystem lib
http://www.boost.org/libs/filesystem/doc/index.htm

It can create a std::fstream using a boost::path

HTH,
Michiel Salters
Jul 22 '05 #3

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

Similar topics

1
by: Rob Kreger | last post by:
This code works on Windows XP with VC7.1 stl(sxl 3.08 from dinkumware.) #include "stdafx.h" #include <iostream> #include <stdio.h> #include <io.h> #include <fstream> #include <sys/locking.h>
14
by: Mike - EMAIL IGNORED | last post by:
Using RH9, from this fragment: fstream theStream_; string fPath = "myFile"; int mode = O_EXCL | O_CREAT; theStream_.open(fPath.c_str(),mode); I get the failure shown below. ...
6
by: David Briggs | last post by:
I am using MS VC++ 6.0 with MFC I have a simple class: #include <fstream.h> class Data { public: CString WriteStr(); Data();
1
by: Macca | last post by:
Hi, I have been using <fstream.h> in stdafx.h,(i'm using MFC) to output to text files. I have now started to use vectors and when i added #include <vector> using namespace std; to...
6
by: Jon Slaughter | last post by:
I'm trying to replace some bytes in a file using fstream but all I seem to be able to do is append or 0 the file then write... Basicaly I just need to replace the first 512 bytes of the file with...
7
by: John Ratliff | last post by:
Is this a legitimate (standards compliant) way to check for errors in file I/O. #include <fstream> fstream output("file.ext", std::ios_base::out, std::ios_base::binary); if (output) { //...
3
by: ratzeel | last post by:
The following snippet code throws an error while compiling on SUN os.. Any idea how to resolve this... #include <iostream.h> #include <fstream.h> #include <math.h> #include <algorithm>...
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...
1
by: MForey | last post by:
I'm attempting to create a program that uses fstream objects to read/write to files. However, it is currently balky at best. The fstream.write call doesn't return an error, but the modified data...
6
by: wiso | last post by:
My problem is this (from: http://www.cplusplus.com/ref/iostream/fstream/open.html) #include <fstream> using namespace std; int main() { fstream f;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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...

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.