Click here to Skip to main content
15,890,186 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Read a file on click event Pin
CodingLover18-Oct-07 20:08
CodingLover18-Oct-07 20:08 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 18:09
CodingLover16-Oct-07 18:09 
GeneralRe: Read a file on click event Pin
David Crow17-Oct-07 4:02
David Crow17-Oct-07 4:02 
GeneralRe: Read a file on click event Pin
CodingLover18-Oct-07 20:16
CodingLover18-Oct-07 20:16 
AnswerRe: Read a file on click event Pin
Mark Salsbery16-Oct-07 6:20
Mark Salsbery16-Oct-07 6:20 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 19:11
CodingLover16-Oct-07 19:11 
GeneralRe: Read a file on click event Pin
chandu00416-Oct-07 20:58
chandu00416-Oct-07 20:58 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 21:08
CodingLover16-Oct-07 21:08 
Ya, this is going to be a long thread. I've do this up to now. Find the number bytes and use it to read the file as follows.

<br />
void CSRFToolDlg::OnBnClickedWrite()<br />
{<br />
	GetDlgItemText(IDC_S_WRITE, readString) ;<br />
    UINT len = readString.GetLength() ;<br />
    openFile.Write(&len, sizeof(UINT)) ; <br />
    if (len > 0)<br />
	{<br />
        openFile.Write((LPVOID)(LPCTSTR)readString, len * sizeof(TCHAR)) ;<br />
	}<br />
    AfxMessageBox("Data write to the file successfully", MB_OK) ;<br />
}<br />
<br />
<br />
void CSRFToolDlg::OnBnClickedRead()<br />
{<br />
	TCHAR tempBuffer[256];<br />
    UINT len;<br />
<br />
    openFile.SeekToBegin();<br />
<br />
    openFile.Read(&len, sizeof(UINT));    <br />
<br />
    if (len > 0)<br />
    {<br />
        openFile.Read(tempBuffer, len * sizeof(TCHAR)) ;<br />
        tempBuffer[len] = _T('\0');<br />
    }<br />
    else<br />
    {<br />
        tempBuffer[0] = _T('\0');<br />
    }<br />
<br />
    SetDlgItemText(IDC_S_READ, tempBuffer) ;<br />
}<br />


Here the issue is, the length of the string is nor write properly to the file. You have my full code, try those two functions there. you will see what I'm saying.

After solving this I'll start a new one for next cases.

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

GeneralRe: Read a file on click event Pin
Mark Salsbery17-Oct-07 5:21
Mark Salsbery17-Oct-07 5:21 
QuestionHow to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:12
Anand Todkar15-Oct-07 19:12 
AnswerRe: How to access all the Editboxes in a form. Pin
Hamid_RT15-Oct-07 19:19
Hamid_RT15-Oct-07 19:19 
GeneralRe: How to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:24
Anand Todkar15-Oct-07 19:24 
GeneralRe: How to access all the Editboxes in a form. Pin
Naveen15-Oct-07 19:28
Naveen15-Oct-07 19:28 
QuestionRe: How to access all the Editboxes in a form. Pin
David Crow16-Oct-07 2:23
David Crow16-Oct-07 2:23 
AnswerRe: How to access all the Editboxes in a form. Pin
Anand Todkar16-Oct-07 2:34
Anand Todkar16-Oct-07 2:34 
GeneralRe: How to access all the Editboxes in a form. Pin
CodingLover15-Oct-07 19:26
CodingLover15-Oct-07 19:26 
GeneralRe: How to access all the Editboxes in a form. Pin
Hamid_RT15-Oct-07 19:38
Hamid_RT15-Oct-07 19:38 
GeneralRe: How to access all the Editboxes in a form. Pin
CodingLover15-Oct-07 19:47
CodingLover15-Oct-07 19:47 
AnswerRe: How to access all the Editboxes in a form. Pin
Naveen15-Oct-07 19:25
Naveen15-Oct-07 19:25 
GeneralRe: How to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:31
Anand Todkar15-Oct-07 19:31 
AnswerRe: How to access all the Editboxes in a form. Pin
Nelek15-Oct-07 21:03
protectorNelek15-Oct-07 21:03 
QuestionList iteration Problem [modified] Pin
ashishbhatt15-Oct-07 19:04
ashishbhatt15-Oct-07 19:04 
AnswerRe: List iteration Problem Pin
zakkas248315-Oct-07 20:11
zakkas248315-Oct-07 20:11 
GeneralRe: List iteration Problem Pin
ashishbhatt15-Oct-07 20:29
ashishbhatt15-Oct-07 20:29 
GeneralRe: List iteration Problem Pin
Nelek15-Oct-07 21:05
protectorNelek15-Oct-07 21: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.