Create a shell namespace extension - c#

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.

Related

Add sound files to build, and find path? C#

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.

Post build event my documents folder generic

I am wondering how to be able to get the my documents path on any machine.
I need to be able to create a new file there and to copy a folder into it.
Here what I got so far, I know its hardcoded so I am looking for some help.
1. make text file in:
C:\Users\ADMIN\Documents\folder1\Projects\project1\copyfolder\textfile.txt
2. copy folder and contents:
C:\ProgramData\test1\copyfolder\
to
C:\Users\ADMIN\Documents\folder1\Projects\project1\copyfolder\
Here's what I got so far:
echo. 2>C:\Users\ADMIN\Documents\folder1\Projects\project1\copyfolder\textfile.txt
But as you see its hardcoded!
Also would %USERPROFILE%\My Documents\ work?
Thanks
Correct syntax for build events is $(USERPROFILE)\Documents
As the visual studio post build is based on MSBuild it should be possible to use a macro that directly accesses the registry (See Registry Properties in the MSBuild documentation).
So you can use
$(registry:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders#Personal)
to query the exact location of the current users Documents folder no matter whether it was moved or not

Open archive file content in OpenFileDiaolg C#

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.

How to get my program name in list of right click menu on any file

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

Include and Reference Resource File from C# class

I have an image that is used in some PDF files that my C# application generates. I know how to reference the image file when it is located in my workspace, but when I compile the program, I don't see the image anywhere in the compiled directory.
Can someone tell me what happened to that file, or do I have to manually package the file along with my program when I send the program to the users? I added the image to the workspace by drag-drop to the resource directory of one of my namespaces.
Check the file's properties in Visual Studio. Have you set the CopyToOutputDirectory property to something besides Do not copy?
Hmm... I'm not sure about the whole drag-drop business, but if it's all working the resource will have been embedded into your assembly.
I suggest you have a look with Reflector - you can see the resources embedded within assemblies using that.
Have a look at the build properties for the item in Solution Explorer - in particular, if the build action is Embedded Resource then it will indeed be built into the assembly.

Categories

Resources