Click here to Skip to main content
15,921,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDeranged CHtmlCtrl Pin
monrobot1328-Oct-02 13:39
monrobot1328-Oct-02 13:39 
GeneralRe: Deranged CHtmlCtrl Pin
Chris Losinger28-Oct-02 20:02
professionalChris Losinger28-Oct-02 20:02 
GeneralRe: Deranged CHtmlCtrl Pin
monrobot1329-Oct-02 6:11
monrobot1329-Oct-02 6:11 
GeneralRe: Deranged CHtmlCtrl Pin
Chris Losinger29-Oct-02 6:15
professionalChris Losinger29-Oct-02 6:15 
GeneralRe: Deranged CHtmlCtrl Pin
monrobot1329-Oct-02 7:10
monrobot1329-Oct-02 7:10 
GeneralCFileDialog?? HELP! Pin
Pett28-Oct-02 13:06
Pett28-Oct-02 13:06 
Hi,

I'm to C ++/mfc and I'm trying to modify a chat program to have the capability to transfer files as well as messages.

I found help from with code to send the file from this forum, but when I implemented it, I keep getting an error, "Unknown error while accessing unnamed file".

I put a button on the client side, and when the person clicks on it, the file dialog box is supposed to open, and the person can choose the file to send.

I get the dialog box, but I get the error right after I choose the file.

I put messages throughout the code to see where the progran has reached, and it seems to be going through fine! I'm really confused!! Confused | :confused: Confused | :confused: Confused | :confused:

I'm pasting the code below. If anyone has any idea what I'm doing wrong please respond.

-------------------------------------------------

void CMainFrame::OnSFile()

{
MessageBox("File Transfer");

CSocket cSocket;
cSocket.Create();
cSocket.Connect((LPCTSTR(m_strServerIP)),m_iFTPort);

CSocketFile sf(&cSocket);
CArchive ar(&sf, CArchive::store);

/*code for CFileDialog goes here*/

static char BASED_CODE szFilter[] = "All Files (*.*)|*.*||";

CString strPath;

CFileDialog m_ldFile(TRUE,".*","*.*",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);

// Initialize the starting directory
//m_ldFile.m_ofn.lpstrInitialDir = _T("C:\\");

// Show the file open dialog and captures the result
//if IDOK
if (m_ldFile.DoModal() == IDOK)
{

strPath = m_ldFile.GetPathName();
CFile myFile(strPath,
CFile::modeRead | CFile::typeBinary);
MessageBox("here");

//get file info
DWORD length = myFile.GetLength();
MessageBox("here2");
char *data = new char[length];
MessageBox("here3");
myFile.Read(data, length);
MessageBox("here4");

//send it across
ar << myFile.GetFileName();
ar << length;
ar.Write(data, length);
delete[] data;
myFile.Close();

}


MessageBox("here5");
}
----------------------------------------------------------------
GeneralEvent Handling Problem in WIN32/MFC App. Pin
loopguru28-Oct-02 12:58
loopguru28-Oct-02 12:58 
QuestionHow to get icons of all opened windows? Pin
Artem Moroz28-Oct-02 12:16
Artem Moroz28-Oct-02 12:16 
AnswerRe: How to get icons of all opened windows? Pin
dabs31-Oct-02 4:46
dabs31-Oct-02 4:46 
GeneralRe: How to get icons of all opened windows? Pin
Artem Moroz31-Oct-02 10:32
Artem Moroz31-Oct-02 10:32 
GeneralRe: How to get icons of all opened windows? Pin
dabs31-Oct-02 13:03
dabs31-Oct-02 13:03 
GeneralSaving with MFC Pin
dinner@628-Oct-02 11:30
dinner@628-Oct-02 11:30 
GeneralRe: Saving with MFC Pin
Christian Graus28-Oct-02 11:34
protectorChristian Graus28-Oct-02 11:34 
GeneralRe: Saving with MFC Pin
valikac28-Oct-02 11:37
valikac28-Oct-02 11:37 
GeneralRe: Saving with MFC Pin
dinner@628-Oct-02 11:59
dinner@628-Oct-02 11:59 
GeneralRe: Saving with MFC Pin
valikac28-Oct-02 12:12
valikac28-Oct-02 12:12 
GeneralRe: Saving with MFC Pin
Christian Graus28-Oct-02 13:25
protectorChristian Graus28-Oct-02 13:25 
GeneralRe: Saving with MFC Pin
ian mariano28-Oct-02 17:38
ian mariano28-Oct-02 17:38 
GeneralCImage -- Can't get it working Pin
nde_plume28-Oct-02 11:26
nde_plume28-Oct-02 11:26 
GeneralRe: CImage -- Can't get it working Pin
Christian Graus28-Oct-02 11:31
protectorChristian Graus28-Oct-02 11:31 
GeneralStrange Problem. Pin
Anonymous28-Oct-02 10:25
Anonymous28-Oct-02 10:25 
GeneralRe: Strange Problem. Pin
Maximilien28-Oct-02 10:35
Maximilien28-Oct-02 10:35 
GeneralRe: Strange Problem. Pin
Anonymous28-Oct-02 11:08
Anonymous28-Oct-02 11:08 

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.