Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 9:24 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 6 posts ] 
Author Question
 Question subject: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Tue Jul 06, 2010 1:25 pm 
Offline
Newbie
User avatar

Joined: Mon May 24, 2010 3:22 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time

i would like the user to input the folder name
then a file will be created by its name too
im using -

cout<<"Enter Foldername";
gets(foldername);

mkric("foldername")

fstream fout;
fstream.open("foldername/foldername",ios::out|ios::app|ios::binary);
fout<<"LOL!!";
fstream.close();

fstream fin;
fstream.open("foldername/foldername",ios::in);
fin.getline(name,size of foldername);
cout<<name;
fstream.close();
....
...
..
.

but i want users to define the filename and folder name!!
i donot want the filename and foldername to be "foldername".

so what should i do??


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Tue Jul 06, 2010 10:42 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time
why don;t you take the folder name from the user and use mkdir function to create this folder.

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Wed Jul 07, 2010 8:49 am 
Offline
Newbie
User avatar

Joined: Mon May 24, 2010 3:22 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
^^
Thank You For Your Prompt Response!

about the code! -

I tried that but when writing a file to that folder its not happening!

Bassically its a Password Program!
heres what exactly i want to do[with some minor codes missing[ie \n's and etc]

fstream fout;

cout<<"ENTER USERNAME";
gets(username);
// its a char type char[51]

"heres the problem"
mkdir("C:\TC\username");

fout.open("C:\TC\username\username",ios::out|ios::app|ios::binary);

// now here i want to make a file whose name is the "username" inside a folder whose name is also the "username".
//and this should be dynamic as in user 1 writes user name as Hello then folder structure should be
//C:\TC\Hello\Hello.whatever! [whatever is the file extention as you know!!]
// an then when user 2 writes username as Good then folder structure should be like
//C:\TC\Good\Good.whatever!

fout<<username;
....
...
..
.

So can you please give me the code for such a program??
any help will be appreciated!! :wave: :gOOd:


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Sun Jul 11, 2010 5:08 pm 
Offline
Newbie
User avatar

Joined: Mon May 24, 2010 3:22 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
I Tried using mkdir();

it does work!!
but i have a problem!!

its like i have 2 char types having same content

char output[] = "C:\\TC\\Library";
char out[]="C:\\TC\\Database";

now when i make a dir by using mkdir(output);
it does get created

but same code mkdir(out);
doesnt create the folder Database!


what is the problem??

i also tried using strcat to conatinate a // and another word to out.!!
but still no success!!!

help me!


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Sun Jul 11, 2010 9:29 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time
what is your operating system, why you don't try c:/tc/Library , i mean using "/"

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create User Defined Folder[directory] in C++[Turbo C++]
PostPosted: Sun Jul 18, 2010 6:55 pm 
Offline
Newbie
User avatar

Joined: Mon May 24, 2010 3:22 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
^^
Somebody told me to per-force use // than / to avoid mistakes done by "/n" or "/t"
also now i have another problem!!

i am able to create a folder initially!
but then the other one is not being creted as the file path being sent is wrong for some reason!!

dunno how to explain it but here's the code -

Code:

char output[] = "C:\\TC\\Student";
char out[] = "C:\\TC\\Database";
char input[] = "C:\\TC\\Student";
char in[] = "C:\\TC\\Database";

fstream userout;
fstream passout;
fstream userin;
fstream passin;

void main()
{
clrscr();
char username[25],password[25],pwd[25],user[25];


cout<<"\n\n\nEnter Username - ";
gets(username);
cout<<"\nEnter Password - ";
gets(password);



{
mkdir(output);
cout<<"\nOld Output - "<<output;

strcat(output,"\\");
strcat(output,username);

mkdir(output);
strcat(output,"\\");
strcat(output,username);

cout<<"\n\nNew output - "<<output;




userout.open(output,ios::out|ios::app|ios::binary);
userout<<username;
userout.close();

}

{
mkdir(out);
strcat(out,"\\");
cout<<"\nOld Out = "<<out;

strcat(out,username);

cout<<"\n Mid1 OUT = "<<out;

mkdir(out);
strcat(out,"\\");

cout<<"\nMid2 Out = "<<out;
strcat(out,password);
cout<<"\nNew Out = "<<out;

passout.open(out,ios::out|ios::app|ios::binary);
passout<<password;
passout.close();

}
getch();
}



it makes the first directory
also writes the file to it

but if you run this program in Borland C++[Windows XP,Vista]
the variable "out" gets vaguely different values somewhat related to the username!!

like if username entered is - Koool
then "out" is oool\kool\kool....

hence the problem!!




Also do you by chnce have the cstring.h Header file?? also if possible windows.h header file??
i need it!!

Thanks in Advanced!!


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 6 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 file exists in upper level folder link  HTML examples  msi_333  0
 php User Registration Form  PHP Tutorials  msi_333  2
 how do i create the classes XX and YY?  Java  Anonymous  0
 how to create a sub domain?  Scripting Language  erinjahanm  1
 how to create a web site  Scripting Language  Anonymous  1

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team