Hello All,
I am having a hard time trying to figure out why my code does not work. I was tasked with writing a small win 32 console app to accept user directory and file name to write to the local machine. My app creates the directory at this point however I cant the file to be written. What am I doing wrong All help appreciated.
int
main(){ char userDirectory [40]= " "; char fileName [40]= " "; char dirAndFile [100]=" ";cout<<
"Enter the fully qualified path of the directory you would like to make: ";cin>>userDirectory;
cout<<
"\nEnter the name of file to create in "<<userDirectory;cin>>fileName;
CreateDirectory(userDirectory, NULL);
strcat_s(dirAndFile,userDirectory);
cout<<dirAndFile;
strcat_s(dirAndFile,fileName);
cout<<dirAndFile;
HANDLE hFile;
hFile= CreateFile(dirAndFile, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
return
0;