Creating Folders In Visual C++

T

TJK

I'm trying to create a Folder using Visual C++ in the Visual Studio
..NET environment. So far I haven't found a successful of doing this.

The folder is to be created using a name given by the user via scanf
or cin. After this I want to be able to use fprintf to create several
files in the folder. I can write the files but don't know how to
create the folder and have the files written in the folder.

Thank you for any help you can give me

TJK

PS I'm still quite new to programming so please forgive me for when I
miss the seemingly obvious :)
 
T

Thomas Matthews

TJK said:
I'm trying to create a Folder using Visual C++ in the Visual Studio
.NET environment. So far I haven't found a successful of doing this.

The folder is to be created using a name given by the user via scanf
or cin. After this I want to be able to use fprintf to create several
files in the folder. I can write the files but don't know how to
create the folder and have the files written in the folder.

Thank you for any help you can give me

TJK

PS I'm still quite new to programming so please forgive me for when I
miss the seemingly obvious :)

Since folders are outside the domain of the C++ language, you should
consult the experts in a Visual C++ newsgroup.

Hint: Folders are also known as directories and many operating
systems treat them similar to files.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
J

Julie

There is no C/C++ function to create/manage/navigate directories (folders) that
I'm aware of.

There is the stdlib system() call that will execute a command through the
command interpreter, but the actual command text will have to be platform
specific.

If you are targeting Windows, then you should ask your question in a more
appropriate newsgroup and you will get some platform-specific ways to do what
you want. Check your news server under microsoft.public.*.
 
E

Edukonis, Michael J.

I'm trying to create a Folder using Visual C++ in the Visual Studio
.NET environment. So far I haven't found a successful of doing this.

The folder is to be created using a name given by the user via scanf
or cin. After this I want to be able to use fprintf to create several
files in the folder. I can write the files but don't know how to
create the folder and have the files written in the folder.

Thank you for any help you can give me

TJK

PS I'm still quite new to programming so please forgive me for when I
miss the seemingly obvious :)

I'm sure you've been told a few times now that this is off topic but here
it is:

#include <windows.h>

int main()
{
int returnValue = 0; //int variable initialized to zero

returnValue = CreateDirectory("c:\\mydirectory", NULL);

return 0;
}

NOTE: CreateDirectory returns a non zero number if succesfull.
You can call GetLastError()
if you need for more info. ALSO: notice the double \\ in c:\\mydirectory. You can do it
that way or c:/mydirectory. The second parameter is security settings for the new directory.
See MSDN for more info on that but NULL just gives it default settings.

Michael Edukonis
 
J

Jack Klein

I'm sure you've been told a few times now that this is off topic but here
it is:

#include <windows.h>

And they were right. windows.h and each and every single thing in it,
and each and every thing in the nested includes it contains, all half
a megabyte or so (last I looked) is 100% off-topic here.

Please don't pollute comp.lang.c++ with off-topic nonsense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top