Winforms - Open external pdf file - winforms

I've Googled and searched stackoverflow for this but I've not found an answer that is suitable.
All I want to do is place a button a form, the code behind this button will contain a reference to a location on a harddrive where a pdf file is stored. All I want to do is have it so that when the user clicks the button the pdf file opens in the machines selected pdf reader (this is an internal application so the 2-3 machines that access it will always have adobe acrobat on them).
I've no idea which (if any) of the built in .NET classes can do this.
EDIT: There will be 100's of pdfs all added throughout time, I will have a path reference to one pdf per order in my system which points to a file storage server where the PDF lies. The PDF is not locally hosted.
How can this be done in the simplest sense?

You can simply use this code
System.Diagnostics.Process.Start(#"c:\myPdf.pdf");
It will open the file you provide with its associated default program

Related

Looking for Editor that can handle .doc or .docx files

i am writing a web application with React, where users can write protocolls for their appointments. The current system is: the web application saves the word file in the local file system, the user edits it and uploads it via a macro in word.
That seems a bit clunky to me and i am not so sure about the security issues of letting the browser directly access the local file system.
So i wanted to let the users edit the files directly via the browser, with an editor similar to GoogleDocs.
Problem is:
Documents have to remain on premis
Converting doc files to a format that can be displayed in a browser and back seems to have some formating issues.
The user must be able to download the file and edit it, in case they have an appointment without internet access and upload it later. So it has to be at least convertable to a document that can be easily edited in Word.
There are so many richtext editor, but from what ive seen none is designed for that use-case. So my question is: Is what i want to do even possible, and if so does anyone know a good editor or library for doing so?

how to retrieve saved file opened from wpf application

My application is in WPF. Application based on video editing, so I am saving the project as a .xml format. And when I double click the saved file, it does not opened in my wpf application. I want to open the saved file in my application when the user double click the saved file icon. Is it possible? I searched the solution, but I didn't get any idea?
You don't say what OS this is for. You need to do one of two things:
1) Change the file association for the .xml type (On windows 10 this is a little more complicated)
or
2) Change your own file type to something else and create a new file association for it. This would be the preferred way.
Answer from previous question/post

Is there a way to disable the "Save" option on a downloadable file, and only allow the "Open/Run" option?

I have an InfoPath form that sits on my SharePoint site. When the file is clicked in the SharePoint directory, the user is usually given the option to Save or Open the file (sometimes dependent on the browser). Saving the file is frowned upon because I want to ensure that the user is using the latest version of the InfoPath form from the SharePoint location.
In a general web sense, is there a way to disallow a user (or at least attempt to prevent a user) from saving the file, and only opening it? I'm not talking about automatically downloading the file when they click it, as I know this is a security problem, and the reason why the open/save prompt exists in the first place. But can a prompt that only allows them to "Open" a downloaded file be shown instead?
And if not in a general web sense, can this be accomplished somehow using SharePoint black magic? I know that single-clicking a file in SharePoint (depending on the list or directory you're looking at) can sometimes result in that file just being opened in its native application without any prompt to the user whatsoever.
hmmm, I'm not sure if this will help but try creating a hyperlink to your form using this format:
https://sharepoint/YourSite/_layouts/FormServer.aspx?XsnLocation=https:sharepoint/YourSite/YourLibrary/Forms/template.xsn&Source=https://sharepoint/YourSite&DefaultItemOpen=1
This will open the form without the open/save dialog box

Read content of folder without AIR in AS3 (no flash.filesystem)

I'm working on a project and I need to dynamically check what is in onhe of my folder. The idea is that I have the id of a quest, and there is a folder name after that id. My code needs to check if this folder exist AND if there is something in it. After that, it show all the picture inside that folder. The goal is that I will just have to add picture in a folder to have them appear in my game.
I tried to find a way to check the content of my folder, but everyone say that I need flash.filesystem, BUT it means that I need to use AIR. AIR does NOT work in FireFox or any other browser.
Here is the website that make me understood that:
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_26118847.html
How can I explore the content of my folders then?
There is absolutely no way to explore the local file system without user interaction in Flash. If you want to do it, you must make an AIR application, which is not browser-based. This is a security feature that is imposed by each browser (you can't do it in JS either) and implemented identically by Adobe.
You can use FileReference to allow a user to select file(s) for Flash to have access to or save a file, but that is the most interaction with the filesystem that will be possible without opening AIR (which is also not limitless. Even with AIR, you won't have full access to the file system and will be locked out of certain directories and prevented from doing certain things)
If the folders are on your server you'll need to rely on a server side script to do the job and pass the result to your app.
If you mean folders on client side computer it's not gonna be possible for security reason.

How to open a binary file directly from a database in c#?

Hey there,
i have a table with a field called "file" full of binary data (The File Itself) how can i open this binary data directly from the database on a click Event for example using c# ?
i dont want to download the file each time to view it .. just view it using the default viewer in the user's OS.
Any Ideas ??
To start off with other than an extremely trivial (throwaway) application I hope that you have setup some layers to abstract the DB access from your UI.
Ultimately your application will have to get the binary object from the DB table and present it as a file to the OS. The applications that come to mind typically want you to pass a filename to them to open them. In essence this means you have to download the file to the local machine with this technique.
The alternative would be to store the files on the filesystem of a server somewhere and place the name/location in your DB (nvarchar). Your application could get the filename/location and pass that to the viewer application.

Resources