Click here to Skip to main content
16,012,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: First error for the night.... Pin
Nick Parker29-Oct-02 17:39
protectorNick Parker29-Oct-02 17:39 
GeneralRe: First error for the night.... Pin
Anatari29-Oct-02 17:48
Anatari29-Oct-02 17:48 
GeneralRe: First error for the night.... Pin
Nick Parker29-Oct-02 17:50
protectorNick Parker29-Oct-02 17:50 
GeneralRe: First error for the night.... Pin
Christian Graus29-Oct-02 18:21
protectorChristian Graus29-Oct-02 18:21 
GeneralRe: First error for the night.... Pin
Nick Parker29-Oct-02 18:28
protectorNick Parker29-Oct-02 18:28 
GeneralGetWindowLong problem Pin
Dan_P29-Oct-02 16:55
Dan_P29-Oct-02 16:55 
GeneralRe: GetWindowLong problem Pin
Paul M Watt29-Oct-02 17:12
mentorPaul M Watt29-Oct-02 17:12 
GeneralPlease Help!! File Transfer!!! Pin
Pett29-Oct-02 16:22
Pett29-Oct-02 16:22 
Hi,
I posted this before, but no one responded. Cry | :((
I'm new 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 program has reached, and it seems to be going through fine! It's also reading the data!

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.
Cry | :(( Cry | :(( Cry | :((

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

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");
}
----------------------------------------------------------------
GeneralRe: Please Help!! File Transfer!!! Pin
Christian Graus29-Oct-02 18:24
protectorChristian Graus29-Oct-02 18:24 
GeneralRe: Please Help!! File Transfer!!! Pin
Pett30-Oct-02 1:28
Pett30-Oct-02 1:28 
Questionactive window hwnd? Pin
imran_rafique29-Oct-02 15:38
imran_rafique29-Oct-02 15:38 
AnswerRe: active window hwnd? Pin
Christian Graus29-Oct-02 15:55
protectorChristian Graus29-Oct-02 15:55 
GeneralRe: active window hwnd? Pin
imran_rafique29-Oct-02 16:11
imran_rafique29-Oct-02 16:11 
GeneralCompiling questions Pin
00zero29-Oct-02 15:14
00zero29-Oct-02 15:14 
GeneralRe: Compiling questions Pin
Christian Graus29-Oct-02 15:22
protectorChristian Graus29-Oct-02 15:22 
GeneralAdding a Toolbar Pin
Anonymous29-Oct-02 14:08
Anonymous29-Oct-02 14:08 
GeneralRe: Adding a Toolbar Pin
Christian Graus29-Oct-02 15:23
protectorChristian Graus29-Oct-02 15:23 
GeneralIM Client Pin
WSK29-Oct-02 14:00
WSK29-Oct-02 14:00 
GeneralRe: IM Client Pin
Paul Ingles29-Oct-02 14:26
Paul Ingles29-Oct-02 14:26 
GeneralSDI Question Pin
Cerb29-Oct-02 13:54
Cerb29-Oct-02 13:54 
GeneralRe: SDI Question Pin
Maximilien29-Oct-02 15:02
Maximilien29-Oct-02 15:02 
GeneralRe: SDI Question Pin
Anatari29-Oct-02 17:33
Anatari29-Oct-02 17:33 
QuestionQuestion, How to fill modal dialog combo box at runtime? Pin
work_to_live29-Oct-02 13:25
work_to_live29-Oct-02 13:25 
AnswerRe: Question, How to fill modal dialog combo box at runtime? Pin
Chris Losinger29-Oct-02 13:41
professionalChris Losinger29-Oct-02 13:41 
GeneralRe: Question, How to fill modal dialog combo box at runtime? Pin
work_to_live29-Oct-02 13:54
work_to_live29-Oct-02 13:54 

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.