|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
[C] Mostra contenuto directory
Salve a tutti è possibile in un programmino chiedere di vedere il contenuto di una directory? Sarebbe il massimo poter mostrare tutti i file con estensione *.dat ad esempio.
Grazie
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Ci sono diversi modi, ad esempio readdir() e ftw(), ma mi sa che funzionano solo su sistemi Unix. Per Windows, fai una ricerca su MSDN.
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Quote:
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Dopo quasi due mesi mi autorispondo...casomai qualcuno come me può trovare utile questa soluzione(sotto linux)
Codice:
int dir(char *indirizzo) {
DIR *pDIR;
struct dirent *pDirEnt;
pDIR = opendir(indirizzo);
if ( pDIR == NULL ) {
fprintf( stderr, "%s %d: opendir() failed (%s)\n",
__FILE__, __LINE__, strerror( errno ));
exit( -1 );
}
pDirEnt = readdir( pDIR );
while ( pDirEnt != NULL ) {
printf( "%s\n", pDirEnt->d_name );
pDirEnt = readdir( pDIR );
}
closedir( pDIR );
return 0;
}
Codice:
system("dir")
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Oct 2006
Città: Roma
Messaggi: 1383
|
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Ci sarà un modo migliore per farlo anche su Windows... Altrimenti pure da Linux potevi usare system("ls").
![]() ciao
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
#7 | |
|
Senior Member
Iscritto dal: Oct 2006
Città: Roma
Messaggi: 1383
|
Quote:
|
|
|
|
|
|
|
#8 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
|
#9 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Visto che una volta risolto il problema ci sono mille proposte(
) faccio una provocazione:non è possibile fare una funzione che vada bene sia sotto windows sia sotto linux? Grazie PS Sto scherzando è che 2 mesi fa
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
|
|
|
|
|
#10 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 02:34.













) faccio una provocazione:








