I want an Open File Dialog with ****.class*** ,****.jar*** filters.
I want that *.jar files will be treated as folders (pressing OK or double-click should display the jar file content [ *.class] ). This capability is very similar to the TotalCommander archive plugin that let you browse inside archive files in-place (without the need to extract them, etc...)
Any ideas how it could be done? Can I use something that is already implemented?
Thanks,
Guy
To do this with that standard windows explorer and common dialogs you will need to write or find an appropiate Shell namespace extension.
A shell namespace extension is an COM object that allows you to present virtual folders in the explorer shell. So in your case the shell extension will allow the user to navigate the jar file structure as if it where a folder on your machine.
You can write a shell extension with managed code, but at least for versions of the framework prior to 4.0 this was not supported by MS because of potention problems with conflict of loading more than one version of the framework into a process. Now that 4.0 supports side by side loading of framework versions, maybe this is supported.
Here is a link to an article on writting a shell namespace extension
http://msdn.microsoft.com/en-us/magazine/cc188741.aspx
I never tried this, but here is an extension that supports treting 7-zip supported files as a folder. Maybe this will help you at least get started if you need to do this yourself.
http://7zipshell.codeplex.com/
Here's an article that describes the opening of Jars in C#:
http://www.codeproject.com/KB/files/opening_jars_cs.aspx
If you combine that either with Chris answer about writing an extension or you write your own dialog if that's easier, you should be able to do what you want.
Related
In my console based program I am wanting to use a sound file at the end of it, I was able to get that to work however when I publish the project and try send it to others I can't get it to include the sound file, how would I accomplish this?
There are many potential solutions. One of them could be embedding the sound file as a resource.
I recommend writing an installer. Sooner or later you'll need one anyway. Maybe you have seen one of them before. It's that thing that always asks for administrator permissions and you click on the Next button until everything is installed properly.
I'd like to point you to InnoSetup, which is a free, text based installer. That's great to use with version control systems. I especially like it, because I can modify every necessary detail in my build script: just write a line of text to that file with the version number and it simply works.
It's very simple to learn and there are plenty of examples available online. The documentation is great and complete.
What you need is the [Files] section, something like
[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"
Source: "MYSOUND.WAV"; DestDir: "{app}"
And then you can just access the music from the same directory as your executable.
See also the question "List of InnoSetup pages in order with parameters and screenshot" which gives you an impression of the capabilities of InnoSetup.
Add the WAV file to your project (right-click your project in Solution Explorer, select Add | Existing Item...)
In Solution Explorer go to the properties for the file you added,
and for Build Action select "Embedded Resource".
Add the following code to your console app:
Code:
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream s = a.GetManifestResourceStream("<assemblyname>.<wavfilename>.wav");
SoundPlayer player = new SoundPlayer(s);
player.PlaySync();
replacing <assemblyname> with the name of your assembly, and <wavfilename> with the name of the WAV file that you added.
For my test code, that line looked like this:
System.IO.Stream s = a.GetManifestResourceStream("ConsoleApp3.tada.wav");
because my assembly name is "ConsoleApp3" and the wav file was called "tada.wav".
Note you will also need to add a using System.Media; to the source code 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.
How does acronis create this virtual folders. For example I created a backup of the folder Example located at C:\Example This is how the backup looks:
If I double click on that file then I could navigate to:
if I right click on that folder I will not get the regular menu that I get with directories. If I double click that directory then I will navigate to the content of that folder as:
Note that the content that I am looking at is inside a file not on windows explorer.
I know that if I send VirtualDir.tib to somewone they will not be able to see the same because they do not have acronis true image installed.
How could I be able to do something similar with c# ?
Edit
Sorry I just updated the title. How will I be able to create a chell namespace extension with c#?
To answer your question about whether it can be done in C#, the answer is no. As is explicitly stated here, writing shell extensions in managed code is entirely unsupported.
This is because shell extension DLLs can be loaded into multiple processes, some of which would already have another version of the CLR loaded.
I used apktool to extract an APK file contents. But for some reasons I need such a tool written in .NET so I do not need to install the JDK in the server.
Is there such a tool?
No. There is no such a tool. You need to start a Process in C# and run the batch file with the arguments using ProcessStartInfo class
I think in another approach, take the APK file and create a Java program that extracts the info I need such as package name, icon resource etc... and then expose it as COM object and use it in my .NET project.
After deep research we can not extract that info in standard functions in Java, since the only way to extract the info is to unzip the APK via the APKTool and read the manifest from the file system.
Another way but hard is to write your own extractor which involves in deep knowledge in the format of the APK.
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.