Click here to Skip to main content
15,891,633 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 20:29
CodingLover15-Oct-07 20:29 
GeneralRe: Read a file on click event Pin
chandu00415-Oct-07 20:27
chandu00415-Oct-07 20:27 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 20:33
CodingLover15-Oct-07 20:33 
GeneralRe: Read a file on click event Pin
chandu00415-Oct-07 20:48
chandu00415-Oct-07 20:48 
AnswerRe: Read a file on click event Pin
Nishad S15-Oct-07 20:41
Nishad S15-Oct-07 20:41 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 20:57
CodingLover15-Oct-07 20:57 
GeneralRe: Read a file on click event Pin
Nishad S15-Oct-07 21:03
Nishad S15-Oct-07 21:03 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 21:14
CodingLover15-Oct-07 21:14 
For open

<br />
void CSRFToolDlg::OnBnClickedOpen()<br />
{<br />
	char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ; // File path to create<br />
<br />
	if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))<br />
	{<br />
		AfxMessageBox("File creates successfully", MB_OK) ;<br />
	}<br />
	else<br />
	{<br />
		AfxMessageBox("Error in file opening", MB_OK) ;<br />
	}<br />
}<br />


For write,

<br />
void CSRFToolDlg::OnBnClickedWrite()<br />
{<br />
	GetDlgItemText(IDC_S_WRITE, readString) ;<br />
	openFile.Write((LPCTSTR)readString, readString.GetLength()) ;<br />
	AfxMessageBox("Data write to the file successfully", MB_OK) ;<br />
}<br />


For read, actually this way is not correct, because it not read the file at all. Just use the string and print.

<br />
void CSRFToolDlg::OnBnClickedRead()<br />
{<br />
	SetDlgItemText(IDC_S_READ, readString) ;<br />
}<br />


I've tried this, but not work.

<br />
void CSRFToolDlg::OnBnClickedRead()<br />
{<br />
	char tempBuffer[256] ;<br />
	UINT readText = 0;<br />
	readText = openFile.Read(tempBuffer, strlen(tempBuffer)) ;<br />
<br />
	SetDlgItemText(IDC_S_READ, readText) ;<br />
}<br />


I appreciate your help all the time...
ErangaSmile | :)

GeneralRe: Read a file on click event Pin
Nishad S15-Oct-07 21:33
Nishad S15-Oct-07 21:33 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 21:40
CodingLover15-Oct-07 21:40 
GeneralRe: Read a file on click event Pin
chandu00415-Oct-07 21:44
chandu00415-Oct-07 21:44 
GeneralRe: Read a file on click event Pin
Nishad S15-Oct-07 22:44
Nishad S15-Oct-07 22:44 
GeneralRe: Read a file on click event Pin
CodingLover15-Oct-07 22:47
CodingLover15-Oct-07 22:47 
GeneralRe: Read a file on click event Pin
Nishad S15-Oct-07 23:55
Nishad S15-Oct-07 23:55 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 0:09
CodingLover16-Oct-07 0:09 
GeneralRe: Read a file on click event Pin
chandu00416-Oct-07 0:14
chandu00416-Oct-07 0:14 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 0:15
CodingLover16-Oct-07 0:15 
GeneralRe: Read a file on click event Pin
Nishad S16-Oct-07 1:14
Nishad S16-Oct-07 1:14 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 1:22
CodingLover16-Oct-07 1:22 
GeneralRe: Read a file on click event Pin
Nishad S16-Oct-07 1:37
Nishad S16-Oct-07 1:37 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 1:41
CodingLover16-Oct-07 1:41 
GeneralRe: Read a file on click event Pin
Nishad S16-Oct-07 1:48
Nishad S16-Oct-07 1:48 
GeneralRe: Read a file on click event Pin
chandu00416-Oct-07 1:40
chandu00416-Oct-07 1:40 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 1:46
CodingLover16-Oct-07 1:46 
GeneralRe: Read a file on click event Pin
chandu00416-Oct-07 2:05
chandu00416-Oct-07 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.