Is it possible to install a right-click extension when in windows file browser, coded in C#?
I will take Winrar as an example:
When in the file browser, you can right click a file and Winrar will be in the list, giving a few options like "Unrar" "extract here" etc.
Is it possible to code the same thing, but when the user right clicks a file, to show my own app in the list, giving two options:
Open with -Myapphere-
Open with -Myapphere- text editor
The first option should start-up my application, and then run the file, being instructioned by the contents IN the file (start, pause etc)
The second option should open the file in my app's editor, DISPLAYING the contents of the file.
I already know how I am going to run / edit it, but how would I let my app now that it has to edit / run the file?
How would I install the right-click extension using the c# installer?
And then how would I open my app and the file with it, when clicked in the explorer?
And how would I make my program notice it is launched from a browser file?
Related
I am trying to deploy my first WPF, C# application to many desktops. For most records in the case database there is a large PDF which I want to store separate from the database and is displayed when a button is pressed (PDF filename equals the id number). It is a search only program, no data is being saved back to the database by users. There are approximately 32,000 pdfs and this number will grow. When I tried to list these files in the project and use ClickOnce to Deploy VS said I had exceeded the maximum manifest size.
Is there a way to deploy my app with ClickOnce and then copy the files with some type of post-install command? Thank you.
Add the files to your project. Mark the Build Action as Content and the Copy to local directory to Always. Then it will include the files with your deployment.
You can also check the Application Files dialog to see if they are there. And if the files have a file extension of XML or something that indicates data, you want to change the option from Include(Data) to Include or Include(Required). If you include a file as data, it is put in the DataDirectory after deployment.
Select a data file in Solution Explorer.
In the Properties window, change the Build Action property to the Content value
2. To mark files as data files
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the file that you wish to mark as data.
In the Publish Status field, select Data File from the drop-down list.
3. To mark files as prerequisites
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the application assembly (.dll file) that you wish to mark as a prerequisite. Note that your application must have a reference to the application assembly in order for it to appear in the list.
In the Publish Status field, select Prerequisite from the drop-down list.
Source: MSDN - How to: Specify Which Files Are Published by ClickOnce
In my C# application i have a help button. When it's pressed I would like for the application to open up a PDF file in the systems default PDF reader, something I can do with a command like Process.Start("pathToPDF").
The problem is that I would like to include the PDF as a resource instead of calling an external file. I do not wish to copy the PDF to the users computer and do not want to host it online or on a NAS.
Right click on your project in the Solution Explorer, then add existing file and choose your pdf (if you cannot find it, make sure you are showing all files and not just .cs files etc.).
Click on the newly added item once in the solution explorer and in the properties window, you set Copy to Output Directory to Copy Always or Copy if newer.
Now you can open the pdf file as expected using Process.Start(filename.pdf);
The only Secure way to show a PDF without providing a file is to include your own Viewer Component (Ex. http://www.o2sol.com/pdfview4net/overview.htm)
Some components allow to load a PDF from Memory (as in a embedded Resource) directly into your Viewer Component, another way would be to create an encrypted binary file to ship with your application and encrypt/load when necessary.
As soon you want to show the PDF in an external viewer ,be aware that the User will have the ability to save the PDF anyway.
Maybe you can explain your reasons to not want to include the file, so we can suggest other solutions to you?
Update:
As noted in your comment, the goal is to have a clean installation.
It would be possible to embed the File as a resource, but then you would
have the problem that if you extract the file temporarily to display it, you can't really control the clean-up of that file, because it's locked by the PDF Reader Application.
So you would end up with the PDF File anyway ;)
What you can do to keep your Application Folder cleaner, is to not install the PDF under that Application Folder but under the "Common Documents" Directory.
For Example: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "MySoftware", "Help.pdf")
Which normally targets: C:\Users\Public\Documents\MySoftware\Help.pdf
I am currently developing a specialized file editor application for the UWP platform. Right now, I have a file association so that a user can click on a file to load it into the app. This loads the file into the "working files" list which allows the user to edit multiple files in a single instance like Visual Studio Code.
Right now, if a user clicks on a file to open it will launch the app and load the file via the OnFileLaunched event. But what I also want to do is load a file when a user clicks on a file and the app is already open to load it into the program. What do I need to do for this?
Take a look on OnActivated method.
You can use OnFileActivated method to handle event when application is open and file clicked
I have an application in C# where I have to select a file and process it. I use Visual Studio's Publish option to generate a Click Once application . But if I want to bundle the file along with the application and set it as default instead of Open File dialog, where should I place the file? The file is an Excel file
first create a folder to hold your custom files in the project,put your excel file inside that folder using add as link in the dialog box.Mark all files as Copy if newer (Copy to output directory property)and just make sure your build action is content.
Thats it..
for more reference
Source 1
Source 2
I am creating an installer for my C# application, and I want to put a link to the configuration file into the start menu, so that users can open it for editing in notepad from the program folder in the start menu.
I seem not to be able to put a link to it however - does anyone know how to do this? (Really, I would just love to put "[targetdir]\myapp.exe.config but VS doesn't let me edit the field, only select from a file browser).
Many thanks,
Rob
I found the solution and it's pretty easy:
Add Project Output for your project in the setup project
Select Project Output from File System in left pane and go to the properties of the project output. Then add a filter *.config to remove the .config file from your project output.
Rename the app.config from your actual project to the output name that your App exe ([ProductName]) will have along with the config extension ofcourse.
Add the [ProductName].config to your setup project as a File.
Create a Shortcut to that file and add it in any setup folder desktop or program folder.
Voila.
You're all set.
Isn't the config file added in your installer? You should be able to select it when prompted for the shortcut target (the "Select Item in Project" dialog). Please note that in this prompt dialog you first need to browse to the folder which contains it (for example double-click "Application Folder").
If the config file is not added, you need to manually add it in "Application Folder". Only then you can create a shortcut to it.
Please note that Visual Studio doesn't support shortcuts to a specific file from a project output which generates multiple files. In this case you can try using a custom action which creates the shortcut through custom code.
I remember doing it in Vs2005 using as below:
File System Editor > Users Programs Menu
Add> Folder
Add file (Say Config file) point it to the its location