FtpFileFind access violation with MS VC++ 6.0

This is a discussion on FtpFileFind access violation with MS VC++ 6.0 within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I have a problem that kept poping up in debug mode at the closing bracket of a function. ...

  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257

    FtpFileFind access violation with MS VC++ 6.0

    Hi everyone,

    I have a problem that kept poping up in debug mode at the closing bracket of a function. I've tested each line of code adding one by one and running through it. Once I added the last line in this snipet I started getting the Access violation error. If I run the code I on't get the error, only in debug mode.
    Code:
    	int radioState =0; 
    	char location = 'N';
    	FileBrowse ConnectFile;
    	CString localfile;
    
    	CInternetSession isession;
    
    	CFtpConnection* pConnect = NULL;
    	CString Server;
    
    	if(location == 'L')
    	{
    		CMyFileDialog  FileDlg(TRUE,0,0,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,0,this);
    	
    		if(FileDlg.DoModal() == IDOK)
    		{
    			localfile = FileDlg.GetPathName();
    			CEdit* pEditSelFile = (CEdit*)GetDlgItem(IDE_FILEPATH);
    	        pEditSelFile->SetWindowText(localfile);
    		}
    
    		InBAF::SetLocation(location);
    		return;
    	}
    	else
    	{
    		InBAF::SetLocation(location);
    		InBAF::SetServerName(location);
    		Server = InBAF::GetServerName();
    	}
    
    	pConnect = isession.GetFtpConnection(_T(Server));
    		
    	//CMyConnection::InitConnection(pConnect);
    	
    	pConnect->SetCurrentDirectory("recording:[000000]");
    		CListBox* pListMain = (CListBox*)GetDlgItem(IDLB_MAINDIR); 
    	CListBox* pListSub = (CListBox*)GetDlgItem(IDLB_SUBDIR);
    
    	
    	//clear the listbox with folders
    	pListMain->ResetContent();
    	pListSub->ResetContent();
    
    	CFtpFileFind finder(pConnect);
    	
    	// Find  the first file 
    	BOOL bWorking = finder.FindFile(_T("*"));
    I'm not sure if there is something else that causes it, but before I put this line in I didn't get the access violation error. What access is the function violating?
    Everything is relative...

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    is pConnect a NULL pointer?

  3. #3
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    No, it's initiated to NULL, but then I assign it to
    Code:
    pConnect = isession.GetFtpConnection(_T(Server));
    Everything is relative...

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    (_T(Server));

    Server is a variable not a string literal it doesnt need the _T macro. Consequently pConnect probably isnt what you thought it was. Maybe you should learn to use asserts.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. access violation in int array
    By George2 in forum C Programming
    Replies: 2
    Last Post: 08-03-2007, 12:28 AM
  2. Access violation when reading a string.
    By Desolation in forum C++ Programming
    Replies: 16
    Last Post: 05-01-2007, 11:25 AM
  3. Error connecting from Dev C++ to MS Access Database
    By Sridar in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2006, 07:09 PM
  4. using DAO without MS Access installed
    By zMan in forum Windows Programming
    Replies: 2
    Last Post: 02-20-2002, 03:14 PM
  5. 0xC0000005: Access Violation
    By Strider in forum Windows Programming
    Replies: 3
    Last Post: 11-07-2001, 02:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21