Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a folder?

Status
Not open for further replies.

panioti

Programmer
Jan 5, 2005
15
US
I want to create a folder in Documents & Settings to hold some working files, but don't know how.
1. How do I find the current user.
2. How do I create the folder.
 
1) Get the current user:
TCHAR szUserName[20];
DWORD dwSize = 20;
::GetUserName(szUserName, &dwSize);

2) Create folders:
int ChcUtils::CreateDirectories(CString &path)
{
int ret=0, pos=0;
if(((pos=path.ReverseFind('\\'))!=-1) && (path!="\\") && (path!="\\\\"))
{
CreateDirectories(path.Left(pos));
DWORD attr=GetFileAttributes(path);
if(!((attr!=0xFFFFFFFF)&&(attr&FILE_ATTRIBUTE_DIRECTORY)))
ret=CreateDirectory(path, NULL);
}
return(ret);
}

William GS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top