I am working on a project that involves parsing a bunch of xml files in a customizable folder.
For sake of saving you several hundred lines of code...
Im using MFC on windows XP to build a dialog app, CString is my primary means of storing string data, all global app settings are in a static class instance AppSettings (appropriately). The problem is, that the user defined folder is stored in a CString, I then need to take that base folder, append a sub folder to it, and create a file in that subfolder, or overwrite it if it exists.
So far I have the writing to file done. As well as creating the subfolder, problem is that when i try to write to a file in the newly created folder, I get crashes. Upon examining, I use CreateDirectory() to create the folder, and it puts the read-only attribute on the folder. The end user is not going to want to have to change all these permissions each time they add an entry (which creates a subfolder). So how do I either A) after creating the folder, change its permissions to writable..or B) set the permisions of the new folder during creation. Right now Im doing this:
folderpath.Format(L"%s\\%s_%s_%i",
App_Settings.ClientFolder.GetString(), m_Clients.at(i).getLastName().GetString(), m_Clients.at(i).getFirstName().GetString(), m_Clients.at(i).getID());
DWORD res = GetFileAttributes(folderpath.GetString());
if (res == INVALID_FILE_ATTRIBUTES)
{
if (!CreateDirectory(folderpath.GetString(),NULL))
{
return false;
}
}
This is in a loop that counts through each of the clients in a vector list, and creates a folder for each one, then writes client data to a file in each respective directory.
Im thinking that it has something to do with LPSECURITY_ATTRIBUTES being set to NULL. But the documentation for the structure is useless to me. Google turns up minimal relevant information about CreateDirectory as well. Any help at this point would be appreciated. Thanks