begin process at 2012 05 27 20:02:19
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

.Net

 > INFORMATIONS SUR FICHIER (VC++ AVEC CFILE, OPENFILENAME) PAS DE GESTION D'ERREURS !!!!

INFORMATIONS SUR FICHIER (VC++ AVEC CFILE, OPENFILENAME) PAS DE GESTION D'ERREURS !!!!


 Information sur la source

Note :
10 / 10 - par 2 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :.Net Niveau :Débutant Date de création :08/05/2002 Date de mise à jour :08/05/2002 14:06:31 Vu :5 817

Auteur : Kinamstrong

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

un petit code pour connaitre les informations sur les fichiers , aucune erreurs sont gerées.le code utilise les classe de base Windows.

Source

  • <<InformationFichier.cpp>>
  • #include "stdafx.h"
  • #include<iostream>
  • #include <string>
  • #include <stdio.h>
  • #include "wingdi.h"
  • using namespace std;
  • enum attribute {
  • NORMAL = 0x00,
  • READONLY = 0x01,
  • HIDDEN = 0x02,
  • SYSTEM = 0x04,
  • VOLUME = 0x08,
  • DIRECTORY = 0x10,
  • ARCHIVE = 0x20
  • };
  • string Getattribut(char str);
  • int main(int argc, char* argv[])
  • {
  • OPENFILENAME Selection;
  • char Chemin[200];
  • char Fichier[50];
  • memset(&Selection,0,sizeof(Selection));
  • Selection.lStructSize =sizeof(OPENFILENAME);
  • Selection.hwndOwner=NULL;
  • Selection.hInstance=NULL;
  • Selection.lpstrFilter=
  • TEXT("Fichiers *.*\0*.*\0\0");
  • Selection.lpstrCustomFilter=NULL;
  • Selection.nMaxCustFilter=1;
  • Selection.nFilterIndex=1;
  • Selection.lpstrFile=Chemin;
  • Selection.nMaxFile=sizeof(Chemin);
  • Selection.lpstrFileTitle=Fichier;
  • Selection.nMaxFileTitle=sizeof(Fichier)-1;
  • Selection.lpstrInitialDir = NULL;
  • Selection.lpstrTitle="choisir un fichier";
  • Selection.Flags=OFN_FILEMUSTEXIST;
  • Selection.Flags=OFN_CREATEPROMPT;
  • Selection.lpstrDefExt =NULL;
  • Selection.lCustData=NULL;
  • Selection.lpfnHook=NULL;
  • Selection.lpTemplateName=NULL;
  • Chemin[0]='\0';
  • GetOpenFileName(&Selection);
  • if (Chemin!='\0'){
  • CFile file;
  • CFileException e;
  • CFileStatus status;
  • file.Open(Chemin,CFile::modeRead, &e);
  • file.GetStatus( Chemin, status );
  • cout<<"Chemin : "<<status.m_szFullName<<endl;
  • cout<<"///////////////////////////////////"<<endl;
  • cout<<"Taille en Octets :"<<status.m_size<<endl;
  • cout<<"///////////////////////////////////"<<endl;
  • cout<<"Atribut : "<<Getattribut(status.m_attribute)<<endl;
  • cout<<"///////////////////////////////////"<<endl;
  • cout<<"Fichier cree le : "<<status.m_ctime.GetDay()<<"/"<<status.m_ctime.GetMonth()<<"/"<<status.m_ctime.GetYear()<<endl ;
  • cout<<"///////////////////////////////////"<<endl;
  • cout<<"Fichier cree a : "<<status.m_ctime.GetHour() <<":"<<status.m_ctime.GetMinute()<<":"<<status.m_ctime.GetSecond()<<endl ;
  • cout<<"///////////////////////////////////"<<endl;
  • char pbuf[100];
  • UINT nBytesRead = file.Read( pbuf, 100 );
  • file.Close();
  • }
  • return 0;
  • }
  • string Getattribut(char str)
  • {
  • string attr1;
  • string attr2;
  • switch (str&0x0f)
  • {
  • case NORMAL:
  • attr1="normal";
  • break;
  • case READONLY:
  • attr1="lecture seule ";
  • break;
  • case HIDDEN:
  • attr1="cache";
  • break;
  • case SYSTEM:
  • attr1="system";
  • break;
  • case VOLUME:
  • attr1="volume";
  • break;
  • case HIDDEN+READONLY:
  • attr1=" cache + lecture seule ";
  • break;
  • case HIDDEN +SYSTEM:
  • attr1=" cache+systeme";
  • break;
  • case HIDDEN +VOLUME:
  • attr1=" cache + volume";
  • break;
  • case SYSTEM +VOLUME:
  • attr1=" systeme + volume";
  • break;
  • case HIDDEN + SYSTEM +VOLUME+READONLY:
  • attr1=" cache + systeme + volume + lecture seule";
  • break;
  • case HIDDEN + SYSTEM +VOLUME:
  • attr1="cache + systeme + volume";
  • break;
  • }
  • switch (str&0xf0)
  • {
  • case DIRECTORY:
  • attr2="repertoire";
  • break;
  • case ARCHIVE:
  • attr2="archive";
  • break;
  • }
  • return attr1+" + " +attr2;
  • }
  • <<stdafx.h>>
  • // stdafx.h : include file for standard system include files,
  • // or project specific include files that are used frequently, but
  • // are changed infrequently
  • //
  • #if !defined(AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_)
  • #define AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_
  • #if _MSC_VER > 1000
  • #pragma once
  • #endif // _MSC_VER > 1000
  • #include <afxwin.h> // MFC core and standard components
  • #include <afxext.h> // MFC extensions
  • #include <afxdisp.h> // MFC Automation classes
  • #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
  • // TODO: reference additional headers your program requires here
  • //{{AFX_INSERT_LOCATION}}
  • // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  • #endif // !defined(AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_)
<<InformationFichier.cpp>>


#include "stdafx.h"
#include<iostream>
#include <string>
#include <stdio.h>
#include "wingdi.h"
using namespace std;
enum attribute {
   NORMAL =    0x00,
   READONLY =  0x01,
   HIDDEN =    0x02,
   SYSTEM =    0x04,
   VOLUME =    0x08,
   DIRECTORY = 0x10,
   ARCHIVE =   0x20
   };

string Getattribut(char str);
int main(int argc, char* argv[])
{
	OPENFILENAME Selection;
	char Chemin[200];
	char Fichier[50];

	memset(&Selection,0,sizeof(Selection));

	Selection.lStructSize =sizeof(OPENFILENAME);
	Selection.hwndOwner=NULL;
	Selection.hInstance=NULL;

	Selection.lpstrFilter=
	TEXT("Fichiers *.*\0*.*\0\0");

	Selection.lpstrCustomFilter=NULL;
	Selection.nMaxCustFilter=1;
	Selection.nFilterIndex=1;
	Selection.lpstrFile=Chemin;
	Selection.nMaxFile=sizeof(Chemin);
	Selection.lpstrFileTitle=Fichier;
	Selection.nMaxFileTitle=sizeof(Fichier)-1;
	Selection.lpstrInitialDir = NULL;
	Selection.lpstrTitle="choisir un fichier";
	Selection.Flags=OFN_FILEMUSTEXIST; 
	Selection.Flags=OFN_CREATEPROMPT; 
	Selection.lpstrDefExt =NULL;
	Selection.lCustData=NULL;
	Selection.lpfnHook=NULL;
	Selection.lpTemplateName=NULL;
	Chemin[0]='\0';
	GetOpenFileName(&Selection);
	if (Chemin!='\0'){
	 CFile file;
	CFileException e;
	CFileStatus status;
	file.Open(Chemin,CFile::modeRead, &e);
	file.GetStatus( Chemin, status );

		cout<<"Chemin : "<<status.m_szFullName<<endl;
		cout<<"///////////////////////////////////"<<endl;
		cout<<"Taille en Octets :"<<status.m_size<<endl;
		cout<<"///////////////////////////////////"<<endl;
		cout<<"Atribut : "<<Getattribut(status.m_attribute)<<endl;
		cout<<"///////////////////////////////////"<<endl;
		cout<<"Fichier cree le : "<<status.m_ctime.GetDay()<<"/"<<status.m_ctime.GetMonth()<<"/"<<status.m_ctime.GetYear()<<endl ;
		cout<<"///////////////////////////////////"<<endl;
		cout<<"Fichier cree a : "<<status.m_ctime.GetHour() <<":"<<status.m_ctime.GetMinute()<<":"<<status.m_ctime.GetSecond()<<endl ;
		cout<<"///////////////////////////////////"<<endl;


	char pbuf[100];
	UINT nBytesRead = file.Read( pbuf, 100 );

	file.Close();
	}
	return 0;
}

string Getattribut(char str)
{
	string attr1;
	string attr2;
	switch (str&0x0f)
	{
	case NORMAL:
		attr1="normal";
		break;

	case READONLY:
		attr1="lecture seule ";
		break;

	case    HIDDEN:
		attr1="cache";
		break;

	case SYSTEM:
		attr1="system";
		break;

	case VOLUME:
		attr1="volume";
		break;
	case HIDDEN+READONLY:
		attr1=" cache + lecture seule ";
		break;
	case HIDDEN +SYSTEM:
		attr1=" cache+systeme";
		break;
	case HIDDEN +VOLUME:
			attr1=" cache + volume";
			break;
	case SYSTEM +VOLUME:
				attr1=" systeme + volume";
				break;
	case HIDDEN + SYSTEM +VOLUME+READONLY:
				attr1=" cache + systeme + volume + lecture seule";
				break;
	case HIDDEN + SYSTEM +VOLUME:
		attr1="cache + systeme + volume";
		break;


	}
	switch (str&0xf0)
	{
	case DIRECTORY:
		attr2="repertoire";
		break;

	case ARCHIVE:
		attr2="archive";
		break;
	}

	return attr1+" + " +attr2;
}


<<stdafx.h>>

// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_)
#define AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls

// TODO: reference additional headers your program requires here

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__080A3C04_6281_11D6_AEA2_0080C8DFB15E__INCLUDED_)
 

 Conclusion

les seuls buggs viennent de la non gestion des erreurs !!!!!


 Sources du même auteur

TIMER 5 SECONDES AVEC HEURE SYSTÈME

 Sources de la même categorie

Source avec Zip Source avec une capture ANALYSEUR LEXICAL par Donald180v
Source avec Zip Source avec une capture MAP_MAKER_JEU par seekplus
Source avec Zip Source avec une capture Source .NET (Dotnet) EMISSION D'UN OCTET SUR LE PORT SÉRIE - CLASSE SERIALPORT par jmchatelet01
Source avec Zip Source .NET (Dotnet) RESOLV EQU DE DEGRES N par darckangel731
Source avec Zip Source avec une capture Source .NET (Dotnet) INTEROP XCHAT / .NET : CHARGEUR DE PLUGINS MANAGÉS par TeBeCo

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,374 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales