Click here to Skip to main content
15,885,869 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionarray instantiation in a __gc struct ??? Pin
JimWDurbin26-Feb-06 12:42
JimWDurbin26-Feb-06 12:42 
AnswerRe: array instantiation in a __gc struct ??? Pin
Ryan Binns26-Feb-06 17:09
Ryan Binns26-Feb-06 17:09 
AnswerRe: array instantiation in a __gc struct ??? Pin
ThatsAlok26-Feb-06 23:52
ThatsAlok26-Feb-06 23:52 
GeneralRe: array instantiation in a __gc struct ??? Pin
JimWDurbin27-Feb-06 4:20
JimWDurbin27-Feb-06 4:20 
Questionsize of buffer for OpenFileName Dlg? Pin
nm_11426-Feb-06 9:03
nm_11426-Feb-06 9:03 
AnswerRe: size of buffer for OpenFileName Dlg? Pin
PJ Arends26-Feb-06 10:30
professionalPJ Arends26-Feb-06 10:30 
AnswerRe: size of buffer for OpenFileName Dlg? Pin
David Crow27-Feb-06 3:19
David Crow27-Feb-06 3:19 
QuestionFile Handle - Serialization Pin
BlitzPackage26-Feb-06 7:54
BlitzPackage26-Feb-06 7:54 
*******Update********
Thanks everyone, I found the problem...I mispelled the directory during one variable initialization. Thanks again for your help.
*******Update********

Everytime I run the code below (Visual Studio .NET 2003), it tells me that a debug assertion has failed. Then when I go into the code to debug it...it goes to "filecore.cpp" and points out the error in the following filecore.cpp function....

***************

void CFile::Write(const void* lpBuf, UINT nCount)<br />
{<br />
	ASSERT_VALID(this);<br />
	ASSERT(m_hFile != INVALID_HANDLE_VALUE); < - - - - **Debug Assertion Error**<br />
<br />
	if (nCount == 0)<br />
		return;     // avoid Win32 "null-write" option<br />
<br />
	ASSERT(lpBuf != NULL);<br />
	ASSERT(AfxIsValidAddress(lpBuf, nCount, FALSE));<br />
<br />
	DWORD nWritten;<br />
	if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL))<br />
		CFileException::ThrowOsError((LONG)::GetLastError(), m_strFileName);<br />
<br />
	// Win95 will not return an error all the time (usually DISK_FULL)<br />
	if (nWritten != nCount)<br />
		AfxThrowFileException(CFileException::diskFull, -1, m_strFileName);<br />
}

***********

The function wherein the problem occurs is as follows...
***********
<br />
void CGCS1View::OnFileSave()<br />
{<br />
	// TODO: Add your command handler code here<br />
    UpdateData();<br />
<br />
	// Get a reference to the document class that will save the file<br />
	CGCS1Doc *pDoc = GetDocument();<br />
<br />
	// Before saving the file, check if there is a folder called<br />
	// "Georgetown Cleaning Services" on the C drive<br />
	// If there is no such a folder, create it<br />
	CreateDirectory(_T("J:\\Software Development\\Georgetown Cleaning Serivces"), NULL);<br />
<br />
	// Get the date that this clenaing order was/is being saved<br />
	CTime DateLeft, TimeLeft, DateExpected, TimeExpected;<br />
	this->m_DateLeft.GetTime(DateLeft);<br />
	this->m_TimeLeft.GetTime(TimeLeft);<br />
	this->m_DateExpected.GetTime(DateExpected);<br />
	this->m_TimeExpected.GetTime(TimeExpected);<br />
<br />
	// Create a string made of the year and the month of the Date Left<br />
	CString strDate = DateLeft.Format(_T("%Y %B"));<br />
<br />
	// Check inside of the Goergetown Cleaning Services folder for<br />
	// a sub-folder made of this year and month<br />
	// If there is such a folder, fine.<br />
	// If that folder doesn't exist, then create it<br />
	CString strPath = CString("C:\\Documents and Settings\\user\\My Documents\\Georgetown Cleaning Services\\") + strDate;<br />
	CreateDirectory(strPath, NULL);<br />
<br />
	// Create a receipt number based on the time the order was process<br />
	CString strReceiptNumber = this->m_ReceiptNumber;<br />
	// Create a file name based on it<br />
	CString strFileName = this->m_ReceiptNumber + ".gcs";<br />
	// Creat the complete path of the file<br />
	CString strFilePath = strPath + CString("\\") + strFileName;<br />
<br />
	// Check if that file exists already<br />
	CFileFind fndFile;<br />
	BOOL exists = fndFile.FindFile(strFilePath);<br />
<br />
	if(exists == TRUE)<br />
	{<br />
		AfxMessageBox("A file with that receipt number exists already\n"<br />
			"Please enter a different receipt number");<br />
		return;<br />
	}<br />
	else<br />
	{<br />
		CString strItem1, strItem2, strItem3, strItem4;<br />
		this->m_Item1.GetWindowText(strItem1);<br />
		this->m_Item2.GetWindowText(strItem2);<br />
		this->m_Item3.GetWindowText(strItem3);<br />
		this->m_Item4.GetWindowText(strItem4);<br />
<br />
		pDoc->CustomerName = m_CustomerName;<br />
		pDoc->CustomerPhone = m_CustomerPhone;<br />
		pDoc->DateLeft = DateLeft;<br />
		pDoc->TimeLeft = TimeLeft;<br />
		pDoc->DateExpected = DateExpected;<br />
		pDoc->TimeExpected = TimeExpected;<br />
		pDoc->ShirtsUnitPrice = m_ShirtsUnitPrice;<br />
		pDoc->ShirtsQuantity = m_ShirtsQuantity;<br />
		pDoc->ShirtsSubTotal = m_ShirtsSubTotal;<br />
		pDoc->PantsUnitPrice = m_PantsUnitPrice;<br />
		pDoc->PantsQuantity = m_PantsQuantity;<br />
		pDoc->PantsSubTotal = m_PantsSubTotal;<br />
		pDoc->strItem1 = strItem1;<br />
		pDoc->UnitPrice1 = m_UnitPrice1;<br />
		pDoc->Quantity1 = m_Quantity1;<br />
		pDoc->SubTotal1 = m_SubTotal1;<br />
		pDoc->strItem2 = strItem2;<br />
		pDoc->UnitPrice1 = m_UnitPrice2;<br />
		pDoc->Quantity2 = m_Quantity2;<br />
		pDoc->SubTotal2 = m_SubTotal2;<br />
		pDoc->strItem3 = strItem3;<br />
		pDoc->UnitPrice3 = m_UnitPrice3;<br />
		pDoc->Quantity3 = m_Quantity3;<br />
		pDoc->SubTotal3 = m_SubTotal3;<br />
		pDoc->strItem4 = strItem4;<br />
		pDoc->UnitPrice4 = m_UnitPrice4;<br />
		pDoc->Quantity4 = m_Quantity4;<br />
		pDoc->SubTotal4 = m_SubTotal4;<br />
		pDoc->CleaningOrder = m_CleaningOrder;<br />
		pDoc->TaxRate = m_TaxRate;<br />
		pDoc->TaxAmount = m_TaxAmount;<br />
		pDoc->OrderTotal = m_OrderTotal;<br />
		pDoc->ReceiptNumber = m_ReceiptNumber;<br />
		<br />
		<br />
<br />
		CFile fleOrder;<br />
       <br />
		fleOrder.Open(strFilePath, CFile::modeCreate | CFile::modeWrite);<br />
		CArchive ar(&fleOrder, CArchive::store);<br />
		pDoc->Serialize(ar);<br />
		<br />
        ar.Close();<br />
		<br />
		fleOrder.Close();<br />
<br />
		UpdateData(FALSE);<br />
<br />
		this->OnBnClickedReset();<br />
	}<br />
<br />
}

***************

Any help you can provide would be greatly appreciated.

Thanks,

-- modified at 8:39 Monday 27th February, 2006
AnswerRe: File Handle - Serialization Pin
Michael Dunn26-Feb-06 8:48
sitebuilderMichael Dunn26-Feb-06 8:48 
GeneralRe: File Handle - Serialization Pin
BlitzPackage26-Feb-06 16:23
BlitzPackage26-Feb-06 16:23 
GeneralRe: File Handle - Serialization Pin
BlitzPackage26-Feb-06 17:09
BlitzPackage26-Feb-06 17:09 
GeneralRe: File Handle - Serialization Pin
Cool Ju26-Feb-06 17:26
Cool Ju26-Feb-06 17:26 
Questionbasic question about c++ Pin
DanYELL26-Feb-06 7:42
DanYELL26-Feb-06 7:42 
AnswerRe: basic question about c++ Pin
BlitzPackage26-Feb-06 7:57
BlitzPackage26-Feb-06 7:57 
GeneralRe: basic question about c++ Pin
DanYELL26-Feb-06 8:48
DanYELL26-Feb-06 8:48 
AnswerRe: basic question about c++ Pin
Michael Dunn26-Feb-06 8:54
sitebuilderMichael Dunn26-Feb-06 8:54 
AnswerRe: basic question about c++ Pin
Hamid_RT26-Feb-06 17:44
Hamid_RT26-Feb-06 17:44 
AnswerRe: basic question about c++ Pin
David Crow27-Feb-06 3:22
David Crow27-Feb-06 3:22 
QuestionDAO in .NET application Pin
Ahmed Al-Lakani26-Feb-06 7:26
Ahmed Al-Lakani26-Feb-06 7:26 
AnswerRe: DAO in .NET application Pin
Ryan Binns26-Feb-06 17:12
Ryan Binns26-Feb-06 17:12 
GeneralRe: DAO in .NET application Pin
Ahmed Al-Lakani27-Feb-06 0:02
Ahmed Al-Lakani27-Feb-06 0:02 
GeneralRe: DAO in .NET application Pin
Ryan Binns27-Feb-06 2:27
Ryan Binns27-Feb-06 2:27 
GeneralRe: DAO in .NET application Pin
Ahmed Al-Lakani27-Feb-06 5:35
Ahmed Al-Lakani27-Feb-06 5:35 
Questionhow to fill round rectangle with gradient color? Pin
Tarek Jabri26-Feb-06 7:07
Tarek Jabri26-Feb-06 7:07 
AnswerRe: how to fill round rectangle with gradient color? Pin
Stephen Hewitt26-Feb-06 11:16
Stephen Hewitt26-Feb-06 11:16 

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.