Skip to content

Commit 6d98018

Browse files
committed
Add project files.
1 parent f682060 commit 6d98018

File tree

6 files changed

+247
-0
lines changed

6 files changed

+247
-0
lines changed

App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
5+
</startup>
6+
</configuration>

ExtractFileProperties.csproj

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ExtractFileProperties</RootNamespace>
10+
<AssemblyName>ExtractFileProperties</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<TargetFrameworkProfile />
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="CommandLine, Version=2.2.1.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
36+
<HintPath>packages\CommandLineParser.2.2.1\lib\net45\CommandLine.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.3.3, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
39+
<HintPath>packages\Microsoft-WindowsAPICodePack-Core.1.1.3.3\lib\net452\Microsoft.WindowsAPICodePack.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.3.3, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
42+
<HintPath>packages\Microsoft-WindowsAPICodePack-Shell.1.1.3.3\lib\net452\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
43+
</Reference>
44+
<Reference Include="System" />
45+
<Reference Include="System.Core" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="Microsoft.CSharp" />
49+
<Reference Include="System.Data" />
50+
<Reference Include="System.Net.Http" />
51+
<Reference Include="System.Xml" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="Program.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<None Include="App.config" />
59+
<None Include="packages.config" />
60+
</ItemGroup>
61+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
62+
</Project>

ExtractFileProperties.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27428.2037
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtractFileProperties", "ExtractFileProperties.csproj", "{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2AD1CBA2-2974-42B7-A7A7-85938AE1A285}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {27C9A44B-C20D-44A8-A549-B3B42DB9F9DC}
24+
EndGlobalSection
25+
EndGlobal

Program.cs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Xml.Serialization;
8+
using CommandLine;
9+
using Microsoft.WindowsAPICodePack.Shell;
10+
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
11+
12+
13+
namespace ExtractFileProperties
14+
{
15+
class Program
16+
{
17+
public class Options
18+
{
19+
[Option('a', "all", Required = false, HelpText = "Read all property values.")]
20+
public bool All { get; set; }
21+
22+
[Option('v', "verbose", Required = false, HelpText = "Set output to verbose messages.")]
23+
public bool Verbose { get; set; }
24+
25+
[Value(0, Min = 1, HelpText = "Files from which to read properties")]
26+
public IEnumerable<string> Files { get; set; }
27+
}
28+
29+
static void Main(string[] args)
30+
{
31+
Parser.Default.ParseArguments<Options>(args)
32+
.WithParsed<Options>(o =>
33+
{
34+
foreach (var f in o.Files)
35+
{
36+
ReadProperties(f, o);
37+
}
38+
});
39+
40+
#if DEBUG
41+
Console.WriteLine("Hit Enter to continue");
42+
Console.ReadLine();
43+
#endif
44+
}
45+
46+
static void ReadProperties(string file, Options o)
47+
{
48+
if (!File.Exists(file))
49+
return;
50+
51+
var data = new Data();
52+
53+
if (o.All)
54+
{
55+
foreach (var prop in new ShellPropertyCollection(file))
56+
{
57+
data.Add(prop);
58+
}
59+
}
60+
else
61+
{
62+
var props = ShellObject.FromParsingName(file).Properties;
63+
data.Add(props.System.Keywords);
64+
data.Add(props.System.Comment);
65+
}
66+
67+
var xmlFile = file + ".props.xml";
68+
69+
using (TextWriter writer = new StreamWriter(xmlFile))
70+
{
71+
data.Serializer.Serialize(writer, data);
72+
}
73+
74+
if (o.Verbose)
75+
Console.WriteLine($"Wrote properties of {file} to {xmlFile}");
76+
}
77+
}
78+
79+
[Serializable]
80+
public class Data
81+
{
82+
public List<Property> Properties { get; private set; } = new List<Property>();
83+
84+
public void Add(IShellProperty p)
85+
{
86+
if (p.CanonicalName != null)
87+
Properties.Add(new Property
88+
{
89+
Name = p.CanonicalName,
90+
Value = p.FormatForDisplay(PropertyDescriptionFormatOptions.None)
91+
});
92+
}
93+
94+
private static XmlSerializer serializer = null;
95+
[XmlIgnore]
96+
public XmlSerializer Serializer
97+
{
98+
get
99+
{
100+
if (serializer == null)
101+
serializer = new XmlSerializer(typeof(Data));
102+
return serializer;
103+
}
104+
}
105+
106+
public class Property
107+
{
108+
[XmlAttribute]
109+
public string Name;
110+
public string Value;
111+
}
112+
}
113+
}

Properties/AssemblyInfo.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ExtractFileProperties")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ExtractFileProperties")]
13+
[assembly: AssemblyCopyright("Copyright © Dijji 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("2ad1cba2-2974-42b7-a7a7-85938ae1a285")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.*")]

packages.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="CommandLineParser" version="2.2.1" targetFramework="net452" />
4+
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.3.3" targetFramework="net452" />
5+
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.3.3" targetFramework="net452" />
6+
</packages>

0 commit comments

Comments
 (0)