I have a program that can display the contents of a .zip file in a TreeView control. There is one thing I cannot figure out though.
What if we want to display file icons beside our files in the TreeView control? How do you get the file icon for a ZipArchiveEntry. I can't find any info on how to do this and there isn't a method for it on the ZipArchiveEntry class as maybe there should be. Same is true of the .Net File class.
Does anyone know how to get the file icon for a ZipArchiveEntry so I can display it next to the filename in the TreeView control? One would think getting the icon of a file would be a simple thing, but not so much...
You can use this (http://www.brad-smith.info/blog/archives/164) utility.
If you have extension you can use second example.
Only Note that icon of specified file or extension should existed in Windows.
Icon smallIcon = IconTools.GetIconForFile(
#"C:\Windows\System32\notepad.exe",
ShellIconSize.SmallIcon
);
Icon largeIcon = IconTools.GetIconForExtension(".html", ShellIconSize.LargeIcon);
Related
We use an industry standard file (PDX) that is basically a zip archive file with the extension changed. I want to allow the user to first select a .pdx file and then allow them to select a file within the archive. I found this answer that shows a very clever way to achieve this using the OpenFileDialog. It works great if the archive has the .zip extension. The problem is when the extension of the archive file is changed to .pdx then the open file dialog will not show the contents of the .pdx file.
Is there a way to achieve this functionality with the OpenFileDialog? I do not want to create my own dialog if there is a simple solution.
Is it possible to copy the PDX file to a temporary folder? Then change the extension to name.pdx.zip, when the user clicks select file, and after that immediately open the zip in the temporary folder?
user clicks open file (the .pdx file), (so the selection window closes)
the program copies the PDX file to a temp folder
change the extension of the new file to name.pdx.zip (inside the temporary folder).
automatically open another file select window into the zip file
I hope I could help.
I have a WPF Window which should display PDF files which I've embedded into an DLL file. (So that it won't be accessible and visible from outside, also to keep it clean as there over 1000 files).
I was able to get the file locations by this statement: pack://application:,,,/SampleClass;component/PDFs/
But when I give this location to Adobe PDF Control like this: axAcroPDF1.LoadFile(fileloc). It is not loading anything. So is there any proper way to access it? or another way to embed files safely?
I have a C# program that I need to embed an image into or perhaps better stated make the exe file portable such that the image will open on any computer and I need the image to open up in the default picture viewer (not a form PictureBox). I do have the image in the resource folder with 'Embed Resource'
System.Diagnostics.Process.Start = WindowsFormsApplication5.Properties.Resources.MyImage;
I realize the above code is invalid, but I am just a coding hobbyist, so I don't know everything. If I could get a little push in the right direction, I would appreciate it.
This might do the trick for you but If you want a Default Image Viewer to open a picture, you need to store that image to somewhere on your disk, thus the Image Viewer could find and open your picture.
var bitmap = new Bitmap(WindowsFormsApplication5.Properties.Resources.MyImage);
bitmap.Save("YourImageLocation");
Process.Start("YourIamgeLocation");
Can you suggest something for changing the files icons in C#? What I means here is that does C# has any class that we can use to change the icons of files. For example, can I replace notepad file icon with doc file icon in c#?
I know we can extract the icon of a file, but I am looking for applying new icon to a file.
let me try to explain it in details. I am working on a windows app that process files. This app creates a special folder and user can create files and folders into this folders. Now when user creates a files, i want to apply custom icon which shows it as under processing. When processing is done, the file icon will be changed to processing complete. I hope this makes sense now.
Thanks
You will have to write custom shell extension for this. Which are known as "Icon Overlay Handlers". This is the same way by which applications like TortoiseSVN add icons in explorer.
See this MSDN article and this code example
I've read about icon handlers, but I am unsure how to work with them.
Let's say I have a C# application (or simply a Windows filesystem object such as a .LNK file) and I want to assign it the icon, a PDF File currently is using (or a MS Word file), though the application is not a PDF file itself.
How are icons assigned / where is that association saved? When using tools such as Resource Hacker I can find the icons within application files (of course a PDF file does not have an icon itself). In the registry under HKCR I can find all file types and their respective openers, where are the icons defined? This classifies as multiple questions - I am most interested in how to assign the system's currently assigned filetype icon (e.g. PDF) to my application.
In HKEY_CLASSES_ROOT there will be an entry for the file extension, for example .pdf. The string under this key is the name of a file type, in this case AcroExch.Document. Look up that key, again in HKEY_CLASSES_ROOT, and you will find either a DefaultIcon or CLSID entry. If it's a CLSID you will need to do one more level of indirection - on my system I end up at HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{B801CA65-A1FC-11D0-85AD-444553540000}. Under the DefaultIcon key you will find the full path to the file containing the icon, and the icon number within the file.
You will need to extract the icon from the file and put it into your application. Note that the icon will be trademarked and/or copyrighted by the company that created it - nobody will come after you if it's for your own personal use, but if you release an application using someone else's icon you could find yourself in trouble.
For .LNK files it should be easy. Just right click, "Properties", "Change icon" and in the next dialog "explore". Search the EXE file of e.g. adobe acrobat, the file icon normally sits in the exe file as secondary icon.
For me the path qould be "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"
Okay, bad example, the document icon is actually in AcroRd32.dll in the same path, but normally you don't have to search much.