Writing a PocketPC program that reads from a couple files using CreateFile. I am able to create two files and write to one no problem when neither file exists. When either or both files exist, they open fine but when I use the new operator at anytime there after I get a runtime error about a byte alignment. I've tried playing with using unicode and multibyte and have tried playing with #pragma pack but no luck.
Code snippets:

// This is a function inside a file i/o class I was creating, it is currently set up for multibyte because I haven't switched it back to unicode

bool CE_FSTREAM::Open(char *file, byte fmode)
{
unsigned int i = 0, x = 0, y;
wchar_t *tmpFile = NULL;

mode = fmode;

if(file == NULL)
{
MessageBox(NULL, L"No file selected to open.", L"Error", MB_OK);
return false;
}

i = strlen(file);

if(temp != NULL)
{
for(y = 0; y < strlen(temp); y++)
fName[y] = temp[y];

for(x = 0; x < i; x++)
fName[y+x] = file[x];

fName[y+x] = '\0';
}

tmpFile = new wchar_t[i+1];
CHARTOWCHAR(tmpFile, fName, i);

hFile = CreateFile(tmpFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
size = GetFileSize(hFile, NULL);

return true;
}

here is the function where I am getting my error. This is the first call to the new operator after the files are opened:

bool loadSettings()
{
// Read settings here, if file not present, do config then save in poles.cfg
int i, x = 0;

if(fileIO == NULL)
fileIO = new CE_FSTREAM();

fileIO->SetPath(settings.filePath);
fileIO->Open((char*)configFile, TEXT_MODE);

// overwrite settings.filepath if different from poles.cfg
if(fileIO->FileSize() <= 9)
{
MessageBox(NULL, L"Failed to load application settings.\nLoading default settings.", L"Error", MB_OK);
fileIO->SetFileCursor(0, NULL, FILE_BEGIN);
fileIO->WriteLnText((void*)DefConfig, 88, FILE_BEGIN);
fileIO->WriteText((void*)"\x04 ", 2, FILE_CURRENT);
//fileIO->SetEndOfFile(FILE_CURRENT);
//setendoffile(FILE_CURRENT);
fileIO->Close();
return false;
}
else
{
if(strcmp(&fileIO->ReadLn(), "[config]") != 0)
{
/*fileIO->WriteLnText((void*)DefConfig, 88, FILE_BEGIN);
fileIO->WriteText((void*)"\x04 ", 2, FILE_CURRENT);*/
fileIO->Close();
return false;
}
else
{
fileIO->Close();
}
}

// Error at create new char
char *f = new char[settings.filePathLength + 11];

for(i = 0; i < settings.filePathLength; i++)
f[i] = settings.filePath[i];

for(i = settings.filePathLength; i < (settings.filePathLength + 9); i++)
{
f[i] = dataFile[x];
x++;
}

f[i] = '\0';

return true;
}