June 3rd, 1999, 10:13 AM
I'm using a workerthread wich waits until a change occurs in a directory
then I check if it is the filetype that this thread should process.
the only problem is that this thread tries to open the file before the file is written completly to disc
this is the code I'm using at the moment
//variables
WIN32_FIND_DATA FoundThis;
lpszFileToFind = "*.dat";
HWND hWnd = (HWND) pParam;
HANDLE hChange = FindFirstChangeNotification("d:\\MyProgram\Read,
FALSE,
FILE_NOTIFY_CHANGE_FILE_NAME
);
while (m_bExit == FALSE) // global variable
{ if(WaitForSingleObject(hChange, 20) == WAIT_OBJECT_0)
{
if (FindFirstFile(lpszFileToFind, &FoundThis) != INVALID_HANDLE_VALUE)
{
PostMessage(hWnd,WM_USER_START,0,0);
}
}
}
the routine reads files before that they are fully writen to disk by another program is there option to stop this.
Or am I completly wrong and is another part of my program to blame.
then I check if it is the filetype that this thread should process.
the only problem is that this thread tries to open the file before the file is written completly to disc
this is the code I'm using at the moment
//variables
WIN32_FIND_DATA FoundThis;
lpszFileToFind = "*.dat";
HWND hWnd = (HWND) pParam;
HANDLE hChange = FindFirstChangeNotification("d:\\MyProgram\Read,
FALSE,
FILE_NOTIFY_CHANGE_FILE_NAME
);
while (m_bExit == FALSE) // global variable
{ if(WaitForSingleObject(hChange, 20) == WAIT_OBJECT_0)
{
if (FindFirstFile(lpszFileToFind, &FoundThis) != INVALID_HANDLE_VALUE)
{
PostMessage(hWnd,WM_USER_START,0,0);
}
}
}
the routine reads files before that they are fully writen to disk by another program is there option to stop this.
Or am I completly wrong and is another part of my program to blame.