I am trying to use the 7z command line in order to accomplish various tasks. For one of these it's important for the program to inspect the archive's content before extracting anything from it. In order to find an interface between my program and 7z I use the '>' sign to redirect standard output into a file. Unfortunately the following code does not work:
std::wstringarchivepath=archive->getPath();//archivepathstd::wstringlogfile=L"db\\logfile.log";//logfilepathSevenZipInterface::executeSevenZip(L" l \""+archivepath+L"\" > "+logfile);
In this example I want to redirect the contents of the archive into a log file and later open it to investigate the archives content. Unfortunately 7z seems to not redirect the output to the file and the operation doesn't even succeed. This is what is printed on the console:
Obviously the error here is that the standard output is redirected to the console, not to the file specified. The second picture appears when I remove the '>' part:
std::wstringarchivepath=archive->getPath();//archivepathSevenZipInterface::executeSevenZip(L" l \""+archivepath+L"\");
Now 7z finishes the operation successfully, but there is no log file I could inspect to analyze the output.
I am trying to use the 7z command line in order to accomplish various tasks. For one of these it's important for the program to inspect the archive's content before extracting anything from it. In order to find an interface between my program and 7z I use the '>' sign to redirect standard output into a file. Unfortunately the following code does not work:
In this example I want to redirect the contents of the archive into a log file and later open it to investigate the archives content. Unfortunately 7z seems to not redirect the output to the file and the operation doesn't even succeed. This is what is printed on the console:
Obviously the error here is that the standard output is redirected to the console, not to the file specified. The second picture appears when I remove the '>' part:
Now 7z finishes the operation successfully, but there is no log file I could inspect to analyze the output.
How do I enforce logging the output to a file?
The interface function:
google / stackoverflow:
"How do I redirect output to a file with CreateProcess?"
I see my mistake. Thanks for the quick reply!