LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 07-05-2004, 05:15 PM   #1
poeta_boy
Member
 
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:

C:\documentation\PackageFrameWriter\PackageFrameWriter.html

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:


if(!fileHandler)
{
cout << "error" << endl;
return;
}


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!

Poeta

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

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
hello:

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!
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


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

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