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

You may find something useful in there:

FileFunction:FileType() LXFramework method #40
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform