Questions tagged [cfile]

The cfile tag should be used for questions about the CFile and CStdioFile classes (and their relatives) in MFC (Microsoft Foundation Classes) for C++ code. You should normally add the C++ (or possibly Visual-C++) and MFC tags too. It is not appropriate for questions tagged C — use the plain 'file' as the tag for such questions.

See CFile class and CStdioFile class on the Microsoft Documentation site for two primary references.

47 questions
0
votes
1 answer

Should path search order be identical for ::ShellExecute and static CFile::GetStatus() on relative path .EXE name?

From within my MFC App, I am doing something like CFileStatus fs; if (CFile::GetStatus("MyOtherProg.exe", fs)) { // found the file ::ShellExecute(NULL, NULL, "MyOtherProg.exe", NULL, NULL, SW_SHOW); } but the full path to the file found in…
franji1
  • 3,088
  • 2
  • 23
  • 43
0
votes
0 answers

CFile::Open no instance of overloaded function

void CMFCApplication1Dlg::OnBnClickedButton1() { CFile cfile_object; cfile_object.Open("c:\\test\\ucancode_cfile_example.txt", CFile::modeCreate | CFile::modeWrite); } Error: No instance of overloaded function CFile::open Please help
Clax
  • 207
  • 2
  • 9
0
votes
1 answer

LPTSTR + CFile Write issue

I am trying to read items from CListBox and writing to a file using CFile. Here is my code int count = m_lstSelectedItems.GetCount(); CFile cfile_object; cfile_object.Open( L"C:\\temp.txt", CFile::modeCreate|CFile::modeReadWrite); for(int i=0;…
atulya
  • 535
  • 2
  • 8
  • 25
0
votes
1 answer

CFile and CStdioFile Reading one byte at a time

Using C++ MFC with Visual Studio 2008, I am trying to using CFile or CStdioFile to read in the last line of a text document, store it, and then reprint it after the file has had text amended to it. I have gotten that part working, the only problem…
user3215251
  • 239
  • 1
  • 16
0
votes
1 answer

Not able to read the contents in the file in MFC using the function Cfile?

I am not able to read the contents in the file if I manually write something in the file...If there are contents existing already am able to read the contents...but if I go and manually write something in the file and try to read I am not able to…
kiddo
  • 1,596
  • 7
  • 31
  • 60
0
votes
1 answer

mfc c++ strange block characters after text written to file

my program has two edit control boxes that display text from a text file, and they both have buttons associated with them that update the text files associated with them if anything is written or deleted in the edit control boxes. i have this code…
0
votes
1 answer

mfc c++ update text file from edit control

I know how to read a txt file, and show it's contents in an edit control, but how do I write to a txt file updating/overwriting it's contents from an edit control? i've looked everywhere, and although I can write to a file with set text, I want to…
0
votes
1 answer

Error in recv()/send() (in Socket) or read()/write() (in CFile)

I used the bottom code to transfer file over socket between 2 clients. When client A wants to send a file to client B, it sends that file to server, after the server receives that file, it sends that file to client B. My code is used to read then…
0
votes
2 answers

MFC CFile write

I am using MFC to write a measurement application. On the first run, I got my data written on first column and on to next row and next row. Here's the question. On the second run, how do I write my data on the second column? CFile…
Ashton
  • 83
  • 1
  • 3
  • 12
0
votes
1 answer

Question About CFile Seek

I am using MFC CFile Seek function. I have a problem about Seek out of file length. CFile cfile; BOOL bResult = cfile.Open( L"C:\\2.TXT", CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::typeBinary |…
user25749
  • 4,825
  • 14
  • 61
  • 83
-1
votes
1 answer

In C, how can I pass the strings from a file into a string array. Notice that main objective is to order the students with respect to their id

The program given below is equalize all name and surname with last ones. The contents of the students.dat ; 2020102054 Name1 Surname1 2021202051 Name2 Surname2 2020302057 Name3 Surname3 2020802053 …
-1
votes
1 answer

Using c to create h file

I have a source file where a typedef struct is defined: typedef struct { unsigned int seed; } generator; generator *create() { generator *g = (generator*)malloc(sizeof(generator)); g->seed = time(0);
 return g; } void…
-1
votes
1 answer

Why Read Garbage Value Form File

I just want to read a file and then update some of its value , But while reading using CFile , It gives garbage value in sFileContent Here is my Code CString sWebAppsFile= _T("C:\\newFile.txt"); CString sFileContent; CFile file; int…
-1
votes
2 answers

Read CByteArray from CFile

I'm writring CByteArray to file: CFile myFile; CByteArray m_baToques; if(myFile.Open(_T(file), CFile::modeReadWrite | CFile::modeCreate)) { myFile.Write(m_baToques.GetData(),m_baToques.GetSize()); …
-1
votes
1 answer

Opening a text in notepad in MFC

Just as the title stated. How do I open a text in notepad in MFC? I used the CFileDialog to open up a "Save As" dialog box like so : TCHAR szFilters[] = _T ("Text files (*.txt)¦*.txt¦All files (*.*)¦*.*¦¦"); CFileDialog dlg (FALSE, _T ("txt"),…
Ashton
  • 83
  • 1
  • 3
  • 12