I have a C# WinForm application. This program is designed to create and open specific files (.cus). Files are created using this program and can be opened in same program.
I am using Advanced Installer to create Installer.
After Installation, I need my program to open file(.cus) when it is double clicked. (Just like, If we dblClick .xls file it loads and opens MS Excel if it is there in system.)
How can I achieve this?
I detail answer will be good to understand.
Let me know if I need to make it more clear.
Thanks in anticipation.
You need to get your installation package to create the file association in Windows when you install your application. I am not sure how to achieve this in Advanced Installer, but most installation packages will allow you to do this.
You will also need to make sure your Winforms application accepts a file path as a parameter to the Main(string[] arg) method, which windows will set to be the .cus file you double clicked on.
Related
I'm currently using C# to build an app using WebView2, however, I need to make it accessible for those who are currently not on Edge. I decided to use a fixed version runtime, as documented here.
I'm going to use "EnsureCoreWebView2Async" to specify my environment.
My question is how do I reference the binary files needed in the "browserExecutableFolder" parameter in "CoreWebView2Environment.CreateAsync" if I'm going to package the project using ClickOnce? I won't know where the user will install the file, so I don't know what directory to reference. Could I just reference the file based on the package directory, like below:
"...\\bin\\Release\\net5.0-windows\\programName.exe.Webview2\\EBWebView\\x64\\EmbeddedBrowserWebView.dll"
...or is there another file reference syntax I would need to use?
Sorry if this seems like a beginner's question, but I just recently started learning C#/.NET and I'm still trying to get the hang of programming altogether. :-)
You can package the binary file in the click once installer. When this gets extracted the binary file will be in the same (i recon) directory as the application installed.
Which click once installer will be used for installing the application?
Once you know where the binary file gets placed on installation and if it is in the same folder as the installed application, you can use the following code for getting to that path.
var exePath = System.Reflection.Assembly.GetEntryAssembly().Location;
Documentation for above
When using it with Path.Combine(exepath, "nameofbinaryfile");
You can get a reference to the binary file.
I'm trying to replace a file in a .appv archive file.
I know you can just rename the file to .zip extract and replace the file.
But when I zip it again and rename it back to .appv the file size is different and i get the following error when opening.
Im trying to change the AppxManifest.xml file or a setting within that without having to open via the UI(cmd, c# or powershell).
Thanks
Open up your sequencer and choose "Modify"
"Update"
Then I am skipping the steps where you upload your .appv file and installer (if you don't need the files from installer, you can always ignore it)
"Continue to modify"
Close the last page and it will automatically jumps to this page
Now, you can open up your package, expand the folder and add files if you want
The best option is to use one of the application packaging tools that supports editing of App-V package. Apart from Advanced Installer that has been already mentioned, take a look at AdminStudio and PACE Suite - both support editing App-V. There may be even more than those two I know.
You cannot zip a package back and expect to work, this is not supported by Microsoft.
Starting with App-V 5.1 the Sequencer from Microsoft can export and import the manifest file from the package, so you can modify it, but from what I know you cannot script this, it must be done from the GUI. The list of powershell cmdlets for the sequencer is quite short.
Also, Advanced Installer can also create and edit App-V packages much easily and faster than the sequencer, but again only from the GUI.
You can also try a free tool, called TweakApp-V, here's an example of you can use it. It has predefined commands to add/delete files and registry.
I have a swf file (little animation) created in swish and I want to put it in my windows form app like a header, I was reviewing the below link but it doesn't say too much, could someone give an example of how to do this?
Embedding Flash in a Windows Forms .NET app
Your link is to an old page. (Circa 2003)
Next, there is a SO question similar to this: AxShockwaveFlashObjects and ShockwaveFlashObjects from Flash ocx
To get the two DLL Files needed, do the following:
Open your command prompt. Switch to the directory that contains the aximp.exe file. Typically; C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>
Enter the following command (you may need to change the name of your COX file to match your version.
aximp.exe -source "C:\WNDOWS\system32\Macromed\Flash\Flash10a.ocx"
Look in the C:\WNDOWS\system32\Macromed\Flash\ directory. Your files should be there.
Add these two files as reference in Visual Studio.
Here is a sample app on MSDN: http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/5815e676-50b0-47f4-964a-c1bcebfdb9a4
I have many kinds of xml-files (all with extension .xml) with different root element name and namespace. I want to associate each type with a different application and also make it possible to have different file-icons for each type. Can this be done using C# .NET?
The only way to handle this is in a similar way to that which Visual Studio uses to handle .sln files which is the Visual Studio Version Selector. This application is the one that gets associated with .sln files and handles providing an icon and an eventual process to handle the specific .sln file. Assuming you have Visual Studio installed, take a look in the registry at HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln to see how it's done.
So basically you need to:
Write an executable that can decide what to do with .xml files
Register the process as the one responsible for handling .xml files
Place logic in your executable, or in configuration that your executable consumes, that decides what to do on a per file basis.
For icons, take a look at the subkey ShellEx\IconHandler. You'll see that it points to (on an x64 machine with Visual Studio 2010 installed) HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{9A2B23E4-2A50-48DB-B3C3-F5EA12947CB8} which lists under InprocServer32 a DLL that is responsible for providing icons for files, in this instance C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSFileHandler.dll. You'll need to implement a similar DLL that shares the configuration/logic of your launcher process to determine what icon to show on a per file basis.
The usual caveat: Writing shell extensions in managed code has always been a big "no no" because shell extensions get loaded into any process that shows the common file dialogs. This can cause merry chaos as, up until .net 4.0, only one version of the CLR can be loaded into a process, so you have to be very sure before doing this. Given that .net 4.0 supports in-process side by side, this may not be an issue for you.
No. To Windows, an XML file is an XML file. The OS doesn't look inside to see what namespace is associated with it; it's just an XML file.
Windows associates file types with their extension, so again, all XML files are XML files. You can see this for yourself: rename a normal .txt file that contains absolutely no XML, and then refresh the view of it's folder in Explorer. You'll see the icon change from a text file image to an XML file image.
There isn't a way that you can do this without having custom extensions or an intermediary program.
Maybe one option would be to have a custom applicaiton which is assigned to handle XML files. When this is program is spawned it works out what the "type" of the file is using one of the XML tags and spawns the correct process accordingly. It's unlikely, however that you can give different "types" different icons.
I have created a File/folder copy utility in C#.net. its working fine. problem is that when i right click on folder than my program's name appear their and its also working fine. but when i right click on any file or group of files and folder. so tell me which and where i need to create a registry key through my program so i can do that.
Not sure I understand the question, but here are some links that might help:
Registering File Types:
How to associate a file extension to the current executable in C#
Filetype association with application (C#)
Windows Shell Integration:
Windows Shell Integration using .NET
http://www.codeproject.com/KB/cs/dateparser.aspx