La taille d'un fichier sur le disque

Résolu
cs_mniajnaa Messages postés 22 Date d'inscription samedi 20 janvier 2007 Statut Membre Dernière intervention 24 décembre 2008 - 22 mai 2007 à 14:27
tibob51 Messages postés 268 Date d'inscription vendredi 30 avril 2004 Statut Membre Dernière intervention 13 mai 2013 - 26 mai 2007 à 23:47
bonsoir

je cherche une api " fontion systeme " qui retourne la taille d'un fichier sur le disque 
  
le language est le c++;

merci d'avance

4 réponses

cs_vicenzo Messages postés 178 Date d'inscription mardi 16 août 2005 Statut Membre Dernière intervention 25 août 2010 1
22 mai 2007 à 19:57
GetFileSize (Win9x, NTx)
GetFileSizeEx (WinNT5 et >)

doc sur msdn
3
tibob51 Messages postés 268 Date d'inscription vendredi 30 avril 2004 Statut Membre Dernière intervention 13 mai 2013 2
26 mai 2007 à 23:47
double Taille_Fichier()


{


double taille;


H=CreateFile(("fichier.ext",GENERIC_READ,NULL,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL );
taille=GetFileSize(H,NULL);
return taille/1024;
}
3
cs_laurent1024 Messages postés 987 Date d'inscription mardi 31 mai 2005 Statut Membre Dernière intervention 30 août 2012 25
22 mai 2007 à 14:48
#include <windows.h>




unsigned
int fsize( constchar * FileName )
{
WIN32_FILE_ATTRIBUTE_DATA attr;
if ( GetFileAttributesEx( FileName, GetFileExInfoStandard, &attr ) == 0 )
{
/* erreur, par exemple fichier non trouvé */
return 0;
}
if ( attr.nFileSizeHigh != 0 )
{
/* attention ce fichier fait plus de 4Go */
}
return attr.nFileSizeLow;
}
0
cs_laurent1024 Messages postés 987 Date d'inscription mardi 31 mai 2005 Statut Membre Dernière intervention 30 août 2012 25
22 mai 2007 à 14:49
désolé pour la mise en page.

#include <windows.h>
unsigned int fsize( const char * FileName )
{
   WIN32_FILE_ATTRIBUTE_DATA attr;
   if ( GetFileAttributesEx( FileName, GetFileExInfoStandard, &attr ) == 0 )
   {
      /* erreur, par exemple fichier non trouvé */
      return 0;
   }
   if ( attr.nFileSizeHigh != 0 )
   {
      /* attention ce fichier fait plus de 4Go */
   }
   return attr.nFileSizeLow;
}
0
Rejoignez-nous