WPF desktop application open local file e.x. (.doc,.pptx,pdf,.xls) - c#

Smart people in the world. Anyone knows.. Can WPF desktop application manages to open a local file in its default open software. To give an example, when i clicks a .doc file in my WPF desktop application, Microsoft Word should open such a file

Simply use Process.Start and pass the file name. This has nothing to do with WPF.

Related

How do I display a PDF Named Destination in Windows Server 2012 or 2016 in default Edge Browser from a .net C# app?

Language: C# .net
I have tried the Adobe method which requires Adobe Reader. Even it does not work well - I want to open the file to a destination, then change the destination as the user clicks on a Context Help icon. I do NOT want multiple new windows to clutter the screen.
I am trying to open a PDF to a named destination using the default PDF reader in Windows 2012 Server. (and same in windows server 2016). I don't want to force users to install Adobe PDF Reader. I want to use the default browser-based reader on a standard install.
WHen I use the Adobe method, if I use the n flag, I get a new window every time - annoying. If I don't use the n flag, I can open ONE window; all subsequent calls to change the topic are ignored.
Open the Windows Setting, click the Apps, select the Default Apps option and choose the "Choose default apps by file type", then find the .pdf file name and choose the Microsoft Edge as default apps to view the file. like this.
Then, using the following code to open the pdf file using Edge browser:
Process.Start("file path. such as: 'file:///C:/Users/XXX/Downloads/pdf.pdf'");
From your description, it seems that the pdf file is located on the remote server, I think you could download to local folder first, then using the above code to display the PDF file.

C# open file from physical path

sorry for asking a silly question it seems to be,
I am new to programming and trying to write a asp .net web application.
One part of the application had generated and saved some document
(like pdf, excel, words, gif, jpg, etc.) to a physical path in server side,
User can choose to download the file by clicking a button
is there something like "window.open(url)" that can raise a file download dialog box with known document type in javascript / c#?
Thanks a lot!!

Save PDF file to isolated storage then launch - Windows phone

I have come to the stage in my app where I need to download a pdf file from a certain URL, save it to disk (on the phone that is), and then as soon as it's saved try and open the document in whatever application is installed on the phone to handle PDFs (Adobe reader).
I have a rather limited understanding of how to save to disk and launch a certain file with another application.
Can someone point me in the right direction or give me some tips on how to accomplish this?
My understanding of windows phone is quite limited and I need to quickly add this feature on the app.
In Windows Phone 7, it is not possible to programmatically start the PDF viewer (it's possible in Windows Phone 8 though). So the best I can suggest is using the WebBrowserTask to open the web browser directly at the PDF's URL, then let the user open the file.
It's definitely not a great user experience, but I've been unable to find any other way (even using a WebBrowser control directly in the app doesn't seem to work).
var task = new WebBrowserTask();
task.Uri = new Uri("http://www.education.gov.yk.ca/pdf/pdf-test.pdf");
task.Show();
Where you saved the PDF in Isolated Storage?
You directly opened the Online PDF file in WebBrowser.
Follow these steps:
1) Download the from URI
2) Save to the Isolation Storage
3) Launch it using the launcher.
Note: 1) If you are downloading the pdf file than use .pdf extension while storing in Isolation Storage.
2)Make sure you have the related software installed in your phone like Adobe for PDF etc.

Open docx in Windows Phone 7 programmatically

I would like to develop an app for printing service in Windows Phone 7. In the app, the users can select file to print out. Is there any way to open docx, xlsx, etc. in WP7 programmatically? I know in iPhone the WebView supports to view many file types. Is there anything similar in WP7?
If you are looking to open the document in Office, try using the WebBrowserTask to navigate to the document. There's a good chance it will open with Office.
If you want to render the document yourself, you are very much out of luck. You could try navigating to the document in a WebBrowser control, but I don't think it's supported.
Besides, there are no printing APIs so there would be no way to print it. If this is an enterprise application (ie. internal to your company), you might consider writing a web service on a local server that can accept DOCX files and print them. You could then call that service from your app to print the docs.
You will not be able to open these types of files from the isolated storage. There is no way for third-party applications to launch the external application required for viewing these file types. All of the files which you have listed in your question are XML-based open source file formats. Depending on how much time you want to spend on this, you could write your own parser or possibly utilize an open-source or commercial one.

How to start application from C# application?

how can i start any application from C#
i mean for example, if i have an openfiledialog and the user opened it and selected any file and opened it, i need this file to opened in its application whatever its extension and its default start application.
i have googled and found that Process.Start takes the file name and its application but i don't know what is the type of the file the user is going o open
thanks in advance for any replies.
Process.Start has several overloads; you want the one that takes only a string. From MSDN:
It can be of any file type for which the extension has been associated with an application installed on the system. For example the file name can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated .doc files with a word processing tool, such as Microsoft Word.
Example:
Process.Start(myOpenFileDialog.FileName);
You can call Process.Start with any filename and the file will open in its default program.

Categories