Here is the problem, setting the item->Caption when reading files from a local disk is fine, no issues at all.

Running the application on a USB drive and trying to set the Caption is mangled on the files it discovers. I do not know why this would be happening, does anyone have an idea?

It is only after the ExtractFileName is called that it occurs, is there anything I can do so it comes out as I would like it to?

The fileName is correct when found using the FindNextFileW(h, &f);

I know I should be attaching a process to debug the code, but I can't remember how to do that in the IDE. I am running out of time, so need your help.

void __fastcall TSQLiteListView::AssignListImageItems(UnicodeString fileName)
    {
    //  make sure that folder path is set when executing or assigning values to database component
    UnicodeString msg = "Hello there. \r\n\r\n " ;
    UnicodeString caption = "I am Here";

    TListItem *item;
    item = Items->Add();

    item->Caption = ExtractFileName(fileName);
    MessageBoxW(0, item->Caption.w_str(), caption.w_str(), MB_OK + MB_ICONINFORMATION);
    if(AssignLargImage)
        item->ImageIndex = ListLargeImageIndex;
    else
        item->ImageIndex = ListSmallImageIndex;
    }

I tried doing lots of things in the wrong place, I'm chasing ghosts in a place where the problem did not exist. I tracked it down to the function I provided here.

1

There are 1 best solutions below

0
On BEST ANSWER

Posting an answer because it may be useful to others, the problem was not with my code at all, the problem related to the memory stick, this is what went down

I created an sqlite db via code, it wrote an empty db which is what I expected so no problem here.

My app automatically adds table when accessing the db file first time, this was not the problem.

The application I am writing is required without reservation to run on the USB drive, there are NO dependencies on system files on the drive, there are NO registry ELEMENTS to be concerned with, the whole idea of the app is to be completely independent.

So, the problem was I built an INNO setup file, it run flawlessly and does it's job, the issue was copying the db file from the computer that created it, a new Surface Go, (brilliant machine) when my app tried to read the usb folder containing file the caption label of the item was mangled.

When I ran the app on the usb and created the file from that instance, everything worked as I had expected it to so, at the end of the day, I was chasing a ghost for a good 15 hrs for pulling my hair out while I have been running out of time to finish it by a date and time I cannot predict.

Sorry for inconvenience.