Click here to Skip to main content
11,641,392 members (59,400 online)
Click here to Skip to main content

Finding Dll's and Exe's under a given directory

, 21 Aug 2007 10.5K 101 8
Rate this:
Please Sign up or sign in to vote.
File_Version is a Simple Tool developed in C#.Net. It will fetch you the Complete Dll and EXE information under any selected directory. Many a times, we may be required to know the information for Dlls\Exe's which gett installed with a particular product .

Screenshot - File_version_information_browse_dialog.png

File_Version is a Simple Tool developed in C#.Net. It will fetch you the Complete Dll and EXE information under any selected directory. Many a times, we may be required to know the information for Dlls\Exe's which gett installed with a particular product. This Tool will give you that information. It will fetch various parameters of Dll Ex:

Once we have this XML, we can write our own XSLT to convert it to any file format we want. I have written an XSLT, which will convert the output XML to an HTML page. Once it finds the information for entire DLL's or EXE's in a given directory, it gives output in an XML and HTML file. The other significant feature is build to build comparison of DLLs. Everytime it writes the output information to XML\HTML files with system date and time stamp. This will help us to store the information with date and time stamping . Thus, we can compare the previous and current found dll information.

Salient features of this tool:

1) It gives a simple UI to browse and select any particular folder.

2) It recursively searches entire directories or nested directories for every file

3) Gives complete DLL\EXE information in an XML format

4) XSLT available and can be modified easily as per the need to convert it to an HTML file format

5) Uses current system date and time for output file naming convention. Thus can store multiple files as repository for comparisons.

6) You can select any output path you wanted to store the files

7) Source code is written in C#.Net. You can alter the code if you want. It is attached in the folder

Prerequisites:

.Net Framework 2.0 need to be installed

How to Use:

1) Copy the dllhtml.xsl file(available in the attached ZIP) in your C: drive

2) Open the folder and click on "File_Version.EXE" file

3) It will then open the UI like this, Click on "Browse" Button to select the directory for search

4) Select the output directory where you wanted the output files to be placed

5) Click on the "Click" Button.

6) It will then two output files. One "<Systemdatedate>_dll_exe.xml" and "<Systemdatedate>_dll_exe.Html"

Once exported to outfiles, it opens the output html file as attached in the source code zip

Ok, below is the source code:

Using the code

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Diagnostics;

using System.IO;

using System.Xml;

using System.Xml.Xsl;

using System.Xml.Schema;

using System.Xml.Serialization;

using System.Windows;

namespace File_version

{

public partial class Form1 : Form

{

private List<string> dirList = new List<string>();

private string XML_File_Path;

static string HTML_File_Path;

static string path_str;

public Form1()

{

InitializeComponent();

}

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

List<string> GetAllDirectories(string rootDirectory)

{

dirList.Add(rootDirectory);

DirectoryInfo di = new DirectoryInfo(rootDirectory);

foreach (DirectoryInfo dir in di.GetDirectories())

{

dirList.Add(dir.FullName.ToString());

if (dir.GetDirectories().Length > 0)

{

GetAllDirectories(dir.FullName.ToString());

}

}

return dirList;

}

private void button1_Click(object sender, EventArgs e)

{

try

{

string main_directory = File_Text.Text.ToString();

List<string> directory = this.GetAllDirectories(main_directory);

path_str = DateTime.Now.Day + "_"+ DateTime.Now.Month+ "_" + DateTime.Now.Year + "_"+ DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second;

XML_File_Path = output_folder.Text.ToString()+ path_str + "dll_Exe.xml";

HTML_File_Path = output_folder.Text.ToString() + path_str + "dll_Exe.Html";

XmlTextWriter tw = new XmlTextWriter(XML_File_Path, null);

tw.Formatting = Formatting.Indented;

tw.WriteStartDocument();

tw.WriteStartElement("dll_exe_Info");

foreach (string str_dir in directory)

{

DirectoryInfo di = new DirectoryInfo(str_dir);

FileInfo[] FiArr = di.GetFiles();

int i = 0;

while (i < FiArr.Length)

{

if ((FiArr[i].Extension == ".dll") || (FiArr[i].Extension == ".exe"))

{

tw.WriteStartElement("File", null);

FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(FiArr[i].FullName);

tw.WriteElementString("Name", FiArr[i].Name);

tw.WriteElementString("Description", myFileVersionInfo.FileDescription);

tw.WriteElementString("Version", myFileVersionInfo.FileVersion);

tw.WriteElementString("Fullpath", FiArr[i].FullName);

tw.WriteElementString("Language", myFileVersionInfo.Language);

tw.WriteElementString("ProductVersion", myFileVersionInfo.ProductVersion);

tw.WriteElementString("InternalName", myFileVersionInfo.InternalName);

tw.WriteElementString("Ispatched", myFileVersionInfo.IsPatched.ToString());

tw.WriteEndElement();

}

i = i + 1;

}

}

tw.WriteEndElement();

tw.WriteEndDocument();

tw.Flush();

tw.Close();

DialogResult result;

result = MessageBox.Show("Dlls Information File successfully created at C:\\dll.xml", "DllInformation", MessageBoxButtons.OK, MessageBoxIcon.Information);

TransformXML(XML_File_Path);

if (result == DialogResult.OK)

{

System.Diagnostics.Process.Start(HTML_File_Path);

MessageBox.Show("Happy Testing");

this.Close();

}

}

catch (Exception d)

{

Console.WriteLine("The process failed: {0}", d.ToString());

}

finally

{

Application.Exit();

}

}

public static void TransformXML(string XML_File_Path)

{

XmlUrlResolver resolver = new XmlUrlResolver( );

resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

XslTransform transform = new XslTransform();

transform.Load(@"c:\\dllHtml.xsl",resolver);

transform.Transform(XML_File_Path, HTML_File_Path, resolver);

}

private void button2_Click(object sender, EventArgs e)

{

FolderBrowserDialog dlg = new FolderBrowserDialog();

dlg.ShowDialog();

if (dlg.ShowDialog() == DialogResult.OK)

{

File_Text.Text = dlg.SelectedPath;

}

}

private void directory_path_TextChanged(object sender, EventArgs e)

{

}

private void button3_Click(object sender, EventArgs e)

{

FolderBrowserDialog dlg = new FolderBrowserDialog();

dlg.ShowDialog();

if (dlg.ShowDialog() == DialogResult.OK)

{

output_folder.Text = dlg.SelectedPath;

}

}

}

}

---------

I need to modify the solution file removing my project specific information for some windows. I will attach the C# solution once Iam done with it in a day or two.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

edukulla
Web Developer
United States United States
Iam currently working with a software company in India.

You may also be interested in...

Comments and Discussions

 
GeneralA Guide To Writing Articles For Code Project Pin
Mark Nischalke21-Aug-07 5:47
mvpMark Nischalke21-Aug-07 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 21 Aug 2007
Article Copyright 2007 by edukulla
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid