|
Hemang Raval wrote: file.Write(recvPack, SObj->packetCounter);
here what is recvPack?
|
|
|
|
|
Actual code is like this. sorry I forgot to write about recvpack which is also unsigned char*.
<br />
<br />
MyObj * obj = new MyObj();<br />
recvpack = obj->sharedObjectFunction((unsigned char*)recvBuff2, len);<br />
<br />
CFile file;<br />
file.Open(CString("d://TestFiles//RTMPServer//ClientToServer_msg3.txt"), CFile::modeCreate | CFile::modeWrite);<br />
file.Write(recvPack, obj->packetCounter);<br />
file.Close();<br />
<br />
Hemang Raval
|
|
|
|
|
you have to answer these also.
1.what does obj->sharedObjectFunction return?
2.if it returns the data in unsigned char *, then what for recvbuff2 is?
3.have you tried by putting recvbuff2 in file.write and see?
i mean like this
file.Write(recvBuff2, obj->packetCounter);
4.and also in debug mode, see, which array is getting the data you actually wanted.
gud luck.
-- modified at 4:05 Friday 26th October, 2007
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Use CArchive class. Read here[^] for more information.
Regards,
Paresh.
|
|
|
|
|
Hello Friends,
In one of my application I need to let use to select the directory. I am using File Open dialog for that. but that Only let user select File. Is there any Way I can use this to select the Directory
This is the code I am using.It Allows me to select *.exe File When Choose EXE in Files of Type in File Open Dialog. but Not able to select the Directoy when Select FOLDER Option.
void FileOpenDlg(WCHAR *Path)
{
OPENFILENAME ofn;
ofn.lStructSize = sizeof ( OPENFILENAME) ;
ofn.hwndOwner = hDlg ;
ofn.hInstance = NULL ;
ofn.lpstrFilter =_T("Application (*.Exe;*.avi) \0 *.Exe;*.avi\0 FOLDER \0 ") ;
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 1 ;
ofn.lpstrFile = Path ;
ofn.nMaxFile = MAX_PATH ;
ofn.lpstrFileTitle = NULL ;
ofn.nMaxFileTitle = MAX_PATH ;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL ;
ofn.Flags = 0 ;
ofn.nFileOffset = 0 ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = NULL ;
ofn.lCustData = 0L ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;
GetOpenFileName(&ofn);
}
|
|
|
|
|
|
Use the followign code:
CString YourClassName::GetFolderName()
{
BROWSEINFO br;
CString title = "Select the folder to convert its files";
char buff[MAX_PATH];
br.hwndOwner = m_hWnd;
br.pidlRoot = NULL;
br.lParam = NULL;
br.lpfn = NULL;
br.lpszTitle =( (LPTSTR) ((LPCTSTR)title));
br.pszDisplayName =(LPTSTR) buff;
br.ulFlags = BIF_RETURNONLYFSDIRS;
LPITEMIDLIST item;
item = ::SHBrowseForFolder ( &br );
::SHGetPathFromIDList ( item, buff );
return buff;
}
Hoping that it will help you.
|
|
|
|
|
Anurag Gandhi wrote: LPITEMIDLIST item;
item = ::SHBrowseForFolder ( &br );
::SHGetPathFromIDList ( item, buff );
return buff;
You need to release the memory allocated for item after you get the path name. As the documentation for SHBrowseForFolder says:
The calling application is responsible for freeing the returned PIDL by using the Shell allocator's IMalloc::Free method. To retrieve a handle to that IMalloc interface, call SHGetMalloc.
LPMALLOC pMalloc;
SHGetMalloc (&pMalloc);
pMalloc->Free (item);
pMalloc->Release ();
Judy
|
|
|
|
|
Thanks for the correction Judy.
|
|
|
|
|
Note my reply to the code that Anurag gave you. Also, prior to using that code, you must have called CoInitialize or CoInitializeEx.
Judy
|
|
|
|
|
How can I find the EOF in a CFile. I've read text file as a CFile in a MFC application. I want to do some process on the file within the EOF file.
I appreciate your help all the time...
Eranga
|
|
|
|
|
can you explain a bit clearly?
|
|
|
|
|
Like this,
<br />
char buffer[5000] ;<br />
CFile ReadFile ;<br />
<br />
whiel(ReadFile is not reach to the end)<br />
{<br />
ReadFile.Read(buffer, 4) ;<br />
}<br />
I want to do it until the end of file. Is that clear.
I appreciate your help all the time...
Eranga
|
|
|
|
|
When you read the file, then the Read API will return the number bytes you read. If it is less than the count you specified, the end of file is reached.
- NS -
|
|
|
|
|
NS17 wrote: If it is less than the count you specified
What you mean here, find the length of the file and check it with the buffer size?
I appreciate your help all the time...
Eranga
|
|
|
|
|
try using CFile::GetPosition().
or what ns17 has suggested also holds good.
say for example, in your read, you specify x bytes to be read.
if the read function returns a value that is less than x then it means that, end of file is reached.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Like this
char buffer[5000] ;
CFile ReadFile ;
whiel(1)
{
if( ReadFile.Read(buffer, 4) < 4 )
break; // End of file reached
}
Hope you got it...
- NS -
|
|
|
|
|
This tread is old now, but I have a clue on this. I'm try it in this way,
First find the length of the file in bytes. Then iteratively do the process within calculated number of bytes. The code is as follows.
<br />
int length = 0 ;<br />
CString str<br />
<br />
length = srf_ReadFile.GetLength()/sizeof(TCHAR) ;<br />
str.Format(_T("File size is %d bytes long."), length) ;<br />
AfxMessageBox(str, MB_OK) ; <br />
What you guys think about it, is there any efficient way to do it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hi all,
I want to make 5 exe's from 1 project only....how to do it? suppose i want to make a set up program in which i want that a main exe that will take various exe's as input and path , a extractor, my uninstall exe and then a setup exe which will place all the given exe's at a mentioned place. I am not getting how to do it....can anybody help me in this....
Thanks in advance
|
|
|
|
|
Create configurations for each of your requirement.
In VS2005, got to "Build | Configuration Manager | Active SOlution COnfiguration | < New >".
Regards,
Paresh.
|
|
|
|
|
In 2005, you can also do this by right-clicking on the solution in Solution Explorer and then selecting Add => New Project
Judy
|
|
|
|
|
hello everybody,
I am saving some configuration in my custom class object.
amd now i want to store this object into file, so anybody know how can i write whole my custom object into file?
Please guide with code if possible.
thanks in advance
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Basically you have to save the information to save by yourself at the time of application exit, and read it on the application loading.
What kind of configuration values are they?
- NS -
|
|
|
|
|
ya i know it but i want to write whole object of my custom class.
I know how to write string values but i dont know about object.
so please tell me how to write it to file?
thanks.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Have a look at serialization.
- NS -
|
|
|
|