Home > Back-end >  Opens the file at the same time the maximum number can be modified?
Opens the file at the same time the maximum number can be modified?

Time:10-26

C + + builder build want to 56 file open at the same time, under the project of simple code is as follows:


The FILE * p [56];

Int I;
AnsiString STR.

for(i=0; i<56. I++)
{
STR=IntToStr (I) + ". TXT ".
If ((p [I]=fopen (STR) c_str (), "wt"))
==NULL)
{
ShowMessage (STR);
return ;
}


}
STR=STR + "complete";
ShowMessage (STR);


Find the can only open the 47 file,

masters excuse me, where it is to limit the?

Can remove this restriction?


thank you

CodePudding user response:

Check the error code, or use CreateFile try again, can also open hundreds of documents are no problem before

CodePudding user response:

Check, whether to open or lock the file has been other programs

CodePudding user response:

Function: open a file
Function prototypes: the FILE * fopen (const char * path, const char * mode).
Related functions: open, fclose, fopen_s [1], _wfopen
The library: & lt; stdio.h>
Return value: file on the smooth, pointing to the current file pointer will be returned, if the file open failed it returns NULL, and the error code to exist error,

Use getlasterror read to see what is wrong

CodePudding user response:


Join the following statement:
Error=GetLastError ();

The return value error=183;

(183) - when the file already exists, unable to create the file,

But there is no 47. TXT this file exists? How can't create?

CodePudding user response:

Come look ha ha thank you

CodePudding user response:

Try using a set of file name?

CodePudding user response:

Name change also not line,

I tried the following code:

for(i=0; i<56. I++)
{
STR="FileNumber" + IntToStr (I) + ". TXT ".
If ((p [I]=fopen (STR) c_str (), "wt"))
==NULL)
{
Error=GetLastError ();

ShowMessage (STR);
return ;
}
fclose (p [I]) .


}
STR=STR + "complete";
ShowMessage (STR);

When combined with fclose (p [I]), you can open the 55 file

That name should do not have what problem?

Is the limit where there is a maximum at the same time open the file,

Masters: you, please give some advice? thank you

CodePudding user response:

Check the C: \ WINDOWS \ system32 \ CONFIG NT set up inside to see?

CodePudding user response:

_getmaxstdio obtain maximum number of open file
_setmaxstdio set the maximum number of open files

CodePudding user response:

references 9 f dataxdata response:
_getmaxstdio extract maximum number of open file
_setmaxstdio set the maximum number of open file


Eldest brother, the two functions are included in the stdio, h?

Compiled in c + + builder is not in the past?

E2268 Call to undefined function '_getmaxstdio'

CodePudding user response:

Checked the, are there, in the two functions of vc CB didn't find inside, CB stdio. Like in the h is _NFILE_ macros, the initial value is 50, as if also is not very good change
Not just try the CreateFile

CodePudding user response:

The openfile should also can open more than 100 files? Exactly where the problem is

CodePudding user response:

Look at this function int _setmaxstdio (
Int newmax
);

I also encountered this problem, the number is the file open, if the TXT file can be opened more than five hundred, different types of file limit is different, can be set by the function above, newmax seems can only go to 2048. The largest can also look at the following link

http://technet.microsoft.com/zh-cn/interopmigration/6e3b887c

CodePudding user response:




The necessary header files




Stdio.h
  • Related