Total members 11890 |It is currently Thu Apr 25, 2024 4:35 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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??




Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time

why don;t you take the folder name from the user and use mkdir function to create this folder.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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:


Author:
Newbie
User avatar Posts: 4
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!


Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time

what is your operating system, why you don't try c:/tc/Library , i mean using "/"

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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!!


Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time
Post new topic Reply to topic  [ 6 posts ] 

  Related Posts  to : Create User Defined Folder[directory] in C++[Turbo C++]
 create folder in asp.net     -  
 java code for listing folder contents from remote folder     -  
 static variable defined in function     -  
 turbo c++     -  
 Maximize Turbo C in Vista     -  
 copy folder     -  
 Get all files in folder     -  
 check folder content using asp     -  
 Zipping a Folder in java     -  
 get Folder path and size     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com