|
-
Sep 7th, 2001, 06:13 PM
#1
Thread Starter
New Member
CreateDirectory
I am just starting with Win32 and have read the Win32 Help.
I want to simply create a directory on my hard drive and am trying the code below. It compiles without error, but does not create the directory:
#define WIN_32_LEAN_AND_MEAN
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpcmdline, int ncmdshow)
{
char dirname[] = "C:\new";
int retval = CreateDirectory(dirname, NULL);
if (retval != 0)
{
MessageBox(NULL, "Directory Created", "Success", MB_OK);
}
else
{
MessageBox(NULL, "Directory Failed", "Failure", MB_OK);
}
return (0);
}
Can someone suggest why the new directory is not created?
Thanks
-
Sep 7th, 2001, 06:42 PM
#2
Fanatic Member
You have to escape the slash (put a backslash before it).
Code:
char dirname[] = "C:\\new";
You have to escape it because it thinks you are escaping the n (\n) which means 'newline.'
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 7th, 2001, 07:15 PM
#3
Thread Starter
New Member
Thanks Wynd,
I'll re-read Win32 help, it didn't seem too specific on that point, but maybe I didn't read it properly.
Thanks for the help
David
-
Sep 7th, 2001, 07:18 PM
#4
Fanatic Member
Well, that is basically for all of C and C++, not just Windows stuff.
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|