Home > Software engineering >  How to store large amounts of data to the variable CStringList
How to store large amounts of data to the variable CStringList

Time:09-16

 if (PathFileExists (PDLG - & gt; Str_upLoadFilePath)) 
{
CFile file_load;
If (file_load. Open (PDLG - & gt; Str_upLoadFilePath, CFile: : modeRead))
{
DWORD file_len=(DWORD) file_load. GetLength ();
PDLG - & gt; I_upLoadMaxNum=file_len/512;
If (PDLG - & gt; I_upLoadMaxNum * 512 & lt; File_len)
{
PDLG - & gt; I_upLoadMaxNum + +;
}
Char carr_fileData [512].

UINT u_readLen;
While (TRUE)
{
U_readLen=file_load. Read (carr_fileData, 512);
Cstrings str_temp str_data;
For (UINT I=0; i {
Str_temp. The Format (_T (" % 02 x "), (BYTE) carr_fileData [I]);
Str_data +=str_temp;
}
PDLG - & gt; List_strUpFile - & gt; AddTail (str_data);
If (u_readLen & lt; 512)
{
break;
}
}
}
File_load. Close ();
}

Read the file is in the thread, list_strUpFile is a member of the dialog box class
CStringList * list_strUpFile;//declare
List_strUpFile=new CStringList;//initialize

The POSITION pos=list_strUpFile - & gt; FindIndex (n);//read the data
Str_data=https://bbs.csdn.net/topics/list_strUpFile-> GetAt (pos);

Fetch the data, when n is larger than 560 or so would be an error



Excuse me, how can store more data CStringList?

My goal is to read multiple files, file size from 1 byte - 5 m, want to put the files into 512 bytes sent a pack of, what better way to read these files, please?



CodePudding user response:

With the new memory, char *

CodePudding user response:

Stack over, stop and take a look at the call Stack, the existence of the invocation of the recursive form?

CodePudding user response:

The use of CStringArray

CodePudding user response:

The
refer to the original poster goddess Boss reply:
 if (PathFileExists (PDLG - & gt; Str_upLoadFilePath)) 
{
CFile file_load;
If (file_load. Open (PDLG - & gt; Str_upLoadFilePath, CFile: : modeRead))
{
DWORD file_len=(DWORD) file_load. GetLength ();
PDLG - & gt; I_upLoadMaxNum=file_len/512;
If (PDLG - & gt; I_upLoadMaxNum * 512 & lt; File_len)
{
PDLG - & gt; I_upLoadMaxNum + +;
}
Char carr_fileData [512].

UINT u_readLen;
While (TRUE)
{
U_readLen=file_load. Read (carr_fileData, 512);
Cstrings str_temp str_data;
For (UINT I=0; i {
Str_temp. The Format (_T (" % 02 x "), (BYTE) carr_fileData [I]);
Str_data +=str_temp;
}
PDLG - & gt; List_strUpFile - & gt; AddTail (str_data);
If (u_readLen & lt; 512)
{
break;
}
}
}
File_load. Close ();
}

Read the file is in the thread, list_strUpFile is a member of the dialog box class
CStringList * list_strUpFile;//declare
List_strUpFile=new CStringList;//initialize

The POSITION pos=list_strUpFile - & gt; FindIndex (n);//read the data
Str_data=https://bbs.csdn.net/topics/list_strUpFile-> GetAt (pos);

Fetch the data, when n is larger than 560 or so would be an error



Excuse me, how can store more data CStringList?

My goal is to read multiple files, file size from 1 byte - 5 m, want to put the files into 512 bytes sent a pack of, what better way to read these files, please?

Loop read your data file data, read 512 bytes of data at a time, and then send?

CodePudding user response:

The
reference 4 floor 7-eleven's response:
Quote: refer to the original poster goddess Boss reply:

 if (PathFileExists (PDLG - & gt; Str_upLoadFilePath)) 
{
CFile file_load;
If (file_load. Open (PDLG - & gt; Str_upLoadFilePath, CFile: : modeRead))
{
DWORD file_len=(DWORD) file_load. GetLength ();
PDLG - & gt; I_upLoadMaxNum=file_len/512;
If (PDLG - & gt; I_upLoadMaxNum * 512 & lt; File_len)
{
PDLG - & gt; I_upLoadMaxNum + +;
}
Char carr_fileData [512].

UINT u_readLen;
While (TRUE)
{
U_readLen=file_load. Read (carr_fileData, 512);
Cstrings str_temp str_data;
For (UINT I=0; i {
Str_temp. The Format (_T (" % 02 x "), (BYTE) carr_fileData [I]);
Str_data +=str_temp;
}
PDLG - & gt; List_strUpFile - & gt; AddTail (str_data);
If (u_readLen & lt; 512)
{
break;
}
}
}
File_load. Close ();
}

Read the file is in the thread, list_strUpFile is a member of the dialog box class
CStringList * list_strUpFile;//declare
List_strUpFile=new CStringList;//initialize

The POSITION pos=list_strUpFile - & gt; FindIndex (n);//read the data
Str_data=https://bbs.csdn.net/topics/list_strUpFile-> GetAt (pos);

Fetch the data, when n is larger than 560 or so would be an error



Excuse me, how can store more data CStringList?

My goal is to read multiple files, file size from 1 byte - 5 m, want to put the files into 512 bytes sent a pack of, what better way to read these files, please?

Loop read your data file data, read 512 bytes of data at a time, and then send?

Yes, after will use data in a file so be saved

CodePudding user response:

Stack overflow is stack memory is used up, usually is to check the status of recursive

Thank zgl7903

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related