Hey
I need to know a code that i can get to create a folder then dump a load of files out of a .zip or something into the folder.
Is it possible?
Printable View
Hey
I need to know a code that i can get to create a folder then dump a load of files out of a .zip or something into the folder.
Is it possible?
system("md c:\whatever");//makes the directory
system("mov c:\files\file.txt c:\whatever");//move to new directory
www.easydos.com has a listing of all the commands...copy and stuff may be better as opposed to move.
I tried it but it doesn't work! :(
I don't really need to know it just want to see if it can be done!
Use double \ instead.Quote:
system("md c:\whatever");//makes the directory
system("mov c:\files\file.txt c:\whatever");//move to new directory
system("md c:\\whatever");
thanks for helping him out shaik, i spaced on that one. :(
Yeah i got that working.
That move never worked.Code:#include <stdlib.h>
int main()
{
system("md c:\\test");//makes the directory
system("mov c:\test.txt c:\test");//move to new directory
system("PAUSE");
return 0;
}
I get this:
'mov' is not recognized as an internal or external command, operable program or batch file.
Press any key to continue.....
I tried doubling the \\ on the mov thing but it says:
cannot open output file Format.exe C:\Dev-C++\mingw32\bin\ld.exe
Permission denied
C:\Documents and Settings\Chris\Desktop\C++\Makefile.win
[Build Error] [Create.exe] Error 1
Any ideas?
Ok thanks got that working.
But what i really want is anyway i can get it to take the file out of a .zip file and into the folder?
dude, search for zip on the board, in the last month i know of at least 20 posts asking this same stupid question
Well sorry but i didn't know did i!
just giving you advice, when you search you'll usually come up with something. Theres been god knowns how many threads on this site.
Thanks, i searched when you told me to didn't have much time to look at it. But i will have another look now.
To expand on Salem's advice for the zip file stuff, awhile ago I created 2 functions for zip file, with his code troubleshooting assistance. You may want to take a look at the following if it will help any:For the code example at hand, I am using the unzip program found on this page for some of my C / C++ programs I code that help my emulation hobby along to move faster.Code:#include "Install.h"
void ZipCheck ( char * FileCheck, char * Name )
{
FILE * Tmp;
if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
{
printf("%s not found, skipping.\n", Name);
}
else
{
/* Nothing */
}
fclose(Tmp);
}
void ZipExtract ( char * SourceFile, char * Destination, char * Name )
{
char * args[6];
args[0] = " -qq "; /* makes unzip.exe quiet */
args[1] = " -C "; /* make unzip.exe noncase-sensative */
args[2] = SourceFile;
args[3] = " -d "; /* create new subdirectory for file(s) */
args[4] = Destination;
args[5] = NULL; /* more output supression to unzip.exe */
printf("Copying..");
spawnv( P_WAIT, "d:\\unzip.exe", args );
printf("\b\b\b\b\b\b\b\b\bCopied - %s\n", Name);
}
A common way to use the functions:If the zip program at question will not work for you, replace it with another. Manipulate the spawn function setup to work in conjunction with the new zip program.Code:#include <stdio.h>
int main ( void )
{
ZipCheck("d:\\directory\\foo.zip", "Foo.zip");
/* arg 1 = zip file, arg 2 = commercial name of zip file */
ZipExtract("d:\\directory\\foo.zip", "c:\\NewDirectory", "Software name");
/* OR */
ZipExtract("d:\\directory\\foo.zip ReadMe.txt", "c:\\Newdirectory\\Docs", "ReadMe File");
return 0;
}
To even expand further:The above program should work so long as you satisfy it's conditions for working.Code:#include <stdio.h>
#include <process.h>
int ZipCheck ( char * FileCheck, char * Name );
int ZipExtract ( char * SourceFile, char * Destination, char * Name );
int main ( void )
{
if ( ZipCheck("c:\\windows\\readme.zip", "ReadMeZip") == 0 )
{
ZipExtract("c:\\windows\\readme.zip",
"c:\\windows\\desktop",
"ReadMe");
}
else
{
printf("Exiting on error");
return 1;
}
return 0;
}
int ZipCheck ( char * FileCheck, char * Name )
{
FILE * Tmp;
if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
{
printf("%s not found, skipping.\n", Name);
return 1;
}
else
{
fclose(Tmp);
return 0;
}
}
int ZipExtract ( char * SourceFile, char * Destination, char * Name )
{
char * args[6];
args[0] = " -qq "; /* makes unzip.exe quiet */
args[1] = " -C "; /* make unzip.exe noncase-sensative */
args[2] = SourceFile;
args[3] = " -d "; /* create new subdirectory for file(s) */
args[4] = Destination;
args[5] = NULL; /* more output supression to unzip.exe */
printf("Copying..");
spawnv( P_WAIT, "c:\\windows\\command\\unzip.exe", args );
printf("\b\b\b\b\b\b\b\b\bCopied - %s\n", Name);
return 0;
}
Ok thanks, i'll try it sometime just i have been busy!