This question already has answers here:
How to validate image file format in C#
(4 answers)
Closed 9 years ago.
I am working for a small project in windows using C# where I need to determine whether a file (without any extension) is a valid image file or not. Is there any inbuilt library function so that I can simplify the task of doing it?
Use
Image.FromFile(path);
It throws if the file of path is not a valid image.
Related
This question already has answers here:
Using .NET, how can you find the mime type of a file based on the file signature not the extension
(20 answers)
Checking file type from base64?
(2 answers)
Closed 1 year ago.
I need to validate the file extension from all sort of types of files that get uploaded. I only have the Base64 string and the filename. I am not allowed to use the file extension from the filename to validate the extension.
I would do it with the magic numbers but I couldn't find a list where all magic numbers from all mime-types/file extensions are listed.
Thanks in advance.
This question already has answers here:
Display a PDF in WPF Application [closed]
(9 answers)
Closed 3 years ago.
I currently have an app in C#/WPF, and I have a manual on how to use it in pdf, and I'm thinking of adding a button that when clicked open the manual ... How can I do this?
Process.Start("C:\Temp\yourname.pdf");
replace the string "C:\Temp\yourname.pdf" with the path and filename for the pdf file you want to open.
This will cause the pdf to open in your systems default pdf application.
You will need: - using System.Diagnostics;
This question already has answers here:
Open file with associated application
(3 answers)
Closed 5 years ago.
I have a string of the file path and I want to open the file. Not in the way that it shows bytes in the console for example, but to open the original file with the program that suits him.
For example if my path shows a .docs file I want it to be opened with Word.
Any suggestions?
System.Diagnostics.Process.Start("CMD.exe",filePath);
This question already has answers here:
How do I get the list of open file handles by process in C#?
(7 answers)
Closed 7 years ago.
Is there a way to get List of Files or FileName which a Process is writing (if possible writing/reading/appending) ,from C# ,which means im talking about Windows (NT,Vista,XP,7).
see here: How do I get the list of open file handles by process in C#?
This question already has answers here:
How to implement glob in C#
(4 answers)
Closed 6 years ago.
Given a path c:\someFolder\**\*.exe. How can I get a list of files using this directory path. I know that one could use Directory.GetFiles(directoryPath) but this only works when there are no wildcard characters in directoryPath.
See: How to implement glob in C#