Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-05-2004, 05:15 PM   #1
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Rep: Reputation: 31
creating a file with la long name on C++

Hi there:

I wanna create a file in C++ with a long name, maybe:


so I put it as a char*

string file("C:\documentation\PackageFrameWriter\PackageFrameWriter.html") ;

ofstream fileHandler(file.c_str(), ios:ut);

but it keeps telling me there's an error creating the file:

cout << "error" << endl;

when I got desperated, I changed the file string for something like

file = "hello.html"

And it worked correctly... my guess is that I cannot create a file with such a long name right? is it true? is there a way around?

thanks for you time!


Last edited by poeta_boy; 07-05-2004 at 05:17 PM.
Old 07-05-2004, 05:27 PM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
First thing, your string is probably not quite right. Every use of a backslash ought to be "escaped". For instance:

string file("C:\\documentation\\PackageFrameWriter\\PackageFrameWriter.html");

However, I don't know whether the "string" data type handles that for you (I don't use C++ much at all).

Second, make sure the parent directories exist. If not, you'll need to create them.
Old 07-05-2004, 06:17 PM   #3
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31

thanks for the quick response.... the problems was with the directory, I didn't create them... actually the string does the work quite ok, and it doesn't need to have scape chars...

Thanks a lot!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
file name too long?? xmdms Linux - Newbie 8 05-25-2013 08:06 AM
fts_read: File name too long angrybeaver Linux - General 2 09-07-2005 06:56 PM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 09:58 PM
dosfs and long file names Ipolit Slackware 3 12-08-2003 01:36 PM
Long File Names Pwcca Linux - General 1 03-05-2003 05:15 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration