Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check The Type of a File
Message
De
23/04/2010 12:39:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Check The Type of a File
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Divers
Thread ID:
01461750
Message ID:
01461750
Vues:
88
Is there any way ti check for the type of a file. I mean, I want to check if a file is an Image File or a PDF or XPS file. I have written a Method for the Image:
        public static bool IsImageFile(string file)
        {
            bool isImageFile = false;
            if (FileManager.FileExist(file))
            {
                try
                {
                    if ((new Bitmap(file)) != null) isImageFile = true;
                }
                catch
                {
                }
            }

            return isImageFile;
        }
It creates a new Bitmap() so if it is a big image the method should be very slow, and I only want to check it.

Any Idea?

Thanks.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform