Create File

Im trying to open a file than it creates the same file but different name.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 case IDB_TESTBUTTON:
                                    {
                                                   
                                                    szFileTitle[0] = '\0'; 
					 szFileName [0] = '\0'; 
if( PopFileDlg( hwnd, szFileName, szFileTitle, TRUE ) )
{
  
HANDLE	hNewFile, hOldFile;	
DWORD	dwWritten, dwRead;
	HEADER	header;	
    BYTE	*bBuffer;		
    
    
    szFileTitle[strchr( szFileTitle, '.' ) - szFileTitle] = '\0';
					// change it to fst -> first
					strcat( szFileTitle, ".fst" );

hNewFile = CreateFile( szFileTitle, 
										   GENERIC_WRITE, 
										   FILE_SHARE_WRITE, 
										   NULL, CREATE_ALWAYS, 
										   FILE_ATTRIBUTE_NORMAL,
										   NULL );
										   
										   
										WriteFile( hNewFile, bBuffer, dwNewSize, &dwRead, NULL );
						// write this buffer to the new file
						WriteFile( hNewFile, bBuffer, dwRead, &dwWritten, NULL );		  
										   
									


    	CloseHandle( hOldFile );
    




The file it creates is 0 kb
You're not checking return codes for errors.
Topic archived. No new replies allowed.