Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check The Type of a File
Message
From
23/04/2010 12:39:12
Antonio Llano
Inmollano S.L.
Getxo, Spain
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
Check The Type of a File
Environment versions
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Miscellaneous
Thread ID:
01461750
Message ID:
01461750
Views:
87
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.
Next
Reply
Map
View

Click here to load this message in the networking platform