GetSaveFileName and GetOpenFileName

Jul 16, 2010 at 7:24pm
I have GetOpenFileName and GetSaveFileName running without errors, but there r 2 problems/questions i have. after Get Open File Name opens a text document how can i write a code to have the integers filtered out of that text file? And for GetSaveFileName, it runs fine but when u type a file for it to save it doesn't actually create the file. Any help would b great. here is my GetSaveFileName's code:

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
36
37
38
39
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include "linker.h"

using namespace std;

OPENFILENAME sfn ;

// a another memory buffer to contain the file name
char syFile[100] ;

int Save()
{
	
	ZeroMemory( &sfn , sizeof( sfn));
	sfn.lStructSize = sizeof ( sfn );
	sfn.hwndOwner = NULL ;
	sfn.lpstrFile = syFile ;
	sfn.lpstrFile[0] = '\0';
	sfn.nMaxFile = sizeof( syFile );
	sfn.lpstrFilter = "Text Documents (*.txt)\0*.TXT\0" ;
	sfn.nFilterIndex =1;
	sfn.lpstrFileTitle = NULL ;
	sfn.nMaxFileTitle = 0 ;
	sfn.lpstrInitialDir=NULL;
	sfn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT|OFN_EXPLORER | OFN_ENABLEHOOK ;

	if (GetSaveFileName( &sfn ) != true)
	{
		cout << "Saving file canceled, closing program in 10 secconds." << endl;
	}

	return 0;
}
Topic archived. No new replies allowed.