Opening A File With Code [duplicate] - c#

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);

Related

How to "pull" an existing pdf into the app? [duplicate]

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;

Search folder and get files [duplicate]

This question already has answers here:
C# Searching for files and folders except in certain folders
(4 answers)
Closed 8 years ago.
I am having one folder containing all .jpg files. Now I am having some part of file name. I want all files whose name contains that part from that folder.
thank you in advance...
You can use DirectoryInfo.EnumerateFiles to do this. And just give it the search pattern.

How to make file to be opened by my app? [duplicate]

This question already has answers here:
Where does Windows store its "Open With" settings?
(3 answers)
Closed 9 years ago.
I have a little bit confusing problem. I'm not a beginner but I don't know how to do it..
For example I've written a program like notepad from which you can open files, save and etc. But when I set any custom format like ".blabla" to be opened by my app it is not working, so how can I make it to be opened by my app?
It is in WinForms
You need an entry in the registry for custom file extensions. You can try inserting a key in the registry as follows:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\

Determine whether a file is a valid image format [duplicate]

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.

How to view which files is Writing a Process [duplicate]

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#?

Categories