Added option to list directories.

This commit is contained in:
aj
2016-12-01 11:15:57 -05:00
parent 543cf5a67f
commit ab7b52571c
5 changed files with 274 additions and 38 deletions

View File

@@ -1,18 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListFiles", "ListFiles\ListFiles.csproj", "{81CC015E-7296-413E-AF57-B6A8CC94662A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Debug|x86.ActiveCfg = Debug|x86
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Debug|x86.Build.0 = Debug|x86
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Release|x86.ActiveCfg = Release|x86
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Release|x86.Build.0 = Release|x86
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CC015E-7296-413E-AF57-B6A8CC94662A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -36,6 +36,9 @@
this.showFullPathsBox = new System.Windows.Forms.CheckBox();
this.searchPatternBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.filesBox = new System.Windows.Forms.RichTextBox();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
@@ -56,34 +59,34 @@
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(633, 29);
this.tableLayoutPanel1.Size = new System.Drawing.Size(710, 39);
this.tableLayoutPanel1.TabIndex = 0;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 8);
this.label1.Location = new System.Drawing.Point(3, 11);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.Size = new System.Drawing.Size(68, 17);
this.label1.TabIndex = 0;
this.label1.Text = "Directory :";
//
// directoryBox
//
this.directoryBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.directoryBox.Location = new System.Drawing.Point(64, 4);
this.directoryBox.Location = new System.Drawing.Point(77, 7);
this.directoryBox.Name = "directoryBox";
this.directoryBox.Size = new System.Drawing.Size(480, 20);
this.directoryBox.Size = new System.Drawing.Size(524, 25);
this.directoryBox.TabIndex = 1;
this.directoryBox.TextChanged += new System.EventHandler(this.directoryBox_TextChanged);
//
// browseButton
//
this.browseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.browseButton.Location = new System.Drawing.Point(550, 3);
this.browseButton.Location = new System.Drawing.Point(607, 4);
this.browseButton.Name = "browseButton";
this.browseButton.Size = new System.Drawing.Size(80, 23);
this.browseButton.Size = new System.Drawing.Size(100, 30);
this.browseButton.TabIndex = 2;
this.browseButton.Text = "Browse...";
this.browseButton.UseVisualStyleBackColor = true;
@@ -92,64 +95,104 @@
// showFileExtensionsBox
//
this.showFileExtensionsBox.AutoSize = true;
this.showFileExtensionsBox.Location = new System.Drawing.Point(148, 70);
this.showFileExtensionsBox.Location = new System.Drawing.Point(143, 59);
this.showFileExtensionsBox.Name = "showFileExtensionsBox";
this.showFileExtensionsBox.Size = new System.Drawing.Size(126, 17);
this.showFileExtensionsBox.TabIndex = 1;
this.showFileExtensionsBox.Text = "Show File Extensions";
this.showFileExtensionsBox.Size = new System.Drawing.Size(144, 21);
this.showFileExtensionsBox.TabIndex = 2;
this.showFileExtensionsBox.Text = "Show file extensions";
this.showFileExtensionsBox.UseVisualStyleBackColor = true;
this.showFileExtensionsBox.CheckedChanged += new System.EventHandler(this.showFileExtensionsBox_CheckedChanged);
//
// showFullPathsBox
//
this.showFullPathsBox.AutoSize = true;
this.showFullPathsBox.Location = new System.Drawing.Point(12, 70);
this.showFullPathsBox.Location = new System.Drawing.Point(12, 59);
this.showFullPathsBox.Name = "showFullPathsBox";
this.showFullPathsBox.Size = new System.Drawing.Size(102, 17);
this.showFullPathsBox.Size = new System.Drawing.Size(115, 21);
this.showFullPathsBox.TabIndex = 1;
this.showFullPathsBox.Text = "Show Full Paths";
this.showFullPathsBox.Text = "Show full paths";
this.showFullPathsBox.UseVisualStyleBackColor = true;
this.showFullPathsBox.CheckedChanged += new System.EventHandler(this.showFullPathsBox_CheckedChanged);
//
// searchPatternBox
//
this.searchPatternBox.Location = new System.Drawing.Point(401, 67);
this.searchPatternBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.searchPatternBox.Location = new System.Drawing.Point(416, 57);
this.searchPatternBox.Name = "searchPatternBox";
this.searchPatternBox.Size = new System.Drawing.Size(100, 20);
this.searchPatternBox.TabIndex = 3;
this.searchPatternBox.Size = new System.Drawing.Size(306, 25);
this.searchPatternBox.TabIndex = 6;
this.searchPatternBox.TextChanged += new System.EventHandler(this.searchPatternBox_TextChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(311, 71);
this.label2.Location = new System.Drawing.Point(311, 60);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(84, 13);
this.label2.TabIndex = 4;
this.label2.Size = new System.Drawing.Size(99, 17);
this.label2.TabIndex = 5;
this.label2.Text = "Search Pattern :";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(12, 86);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(85, 21);
this.checkBox1.TabIndex = 3;
this.checkBox1.Text = "Show files";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.showFullPathsBox_CheckedChanged);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(143, 86);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(124, 21);
this.checkBox2.TabIndex = 4;
this.checkBox2.Text = "Show directories";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.showFullPathsBox_CheckedChanged);
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(650, 90);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(72, 17);
this.linkLabel1.TabIndex = 7;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Refresh list";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// filesBox
//
this.filesBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.filesBox.Location = new System.Drawing.Point(12, 93);
this.filesBox.Location = new System.Drawing.Point(12, 113);
this.filesBox.Name = "filesBox";
this.filesBox.Size = new System.Drawing.Size(633, 400);
this.filesBox.TabIndex = 5;
this.filesBox.Size = new System.Drawing.Size(710, 441);
this.filesBox.TabIndex = 8;
this.filesBox.Text = "";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(657, 505);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(734, 566);
this.Controls.Add(this.filesBox);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label2);
this.Controls.Add(this.searchPatternBox);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.showFullPathsBox);
this.Controls.Add(this.showFileExtensionsBox);
this.Controls.Add(this.tableLayoutPanel1);
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ListFiles";
@@ -170,6 +213,9 @@
private System.Windows.Forms.CheckBox showFullPathsBox;
private System.Windows.Forms.TextBox searchPatternBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.RichTextBox filesBox;
}
}

View File

@@ -3,6 +3,7 @@ using System.Timers;
using System.Windows.Forms;
using Timer = System.Timers.Timer;
using System.IO;
using System.Collections.Generic;
namespace ListFiles
{
@@ -55,8 +56,25 @@ namespace ListFiles
if (!Directory.Exists(dir))
return;
Directory.GetFi
var files = Directory.GetFiles(dir, SearchPattern);
var list = new List<string>();
if (checkBox1.Checked)
list.AddRange(GetFileList(dir));
if (checkBox2.Checked)
list.AddRange(GetDirectoryList(dir));
list.Sort();
foreach (var path in list)
filesBox.AppendText(path + Environment.NewLine);
}
private List<string> GetFileList(string searchPath)
{
var list = new List<string>();
var files = Directory.GetFiles(searchPath, SearchPattern);
var showExt = showFileExtensionsBox.Checked;
var showPath = showFullPathsBox.Checked;
@@ -65,13 +83,36 @@ namespace ListFiles
var ext = Path.GetExtension(file);
var name = Path.GetFileNameWithoutExtension(file);
var path = showPath ? Path.Combine(dir, name) : name;
var path = showPath ? Path.Combine(searchPath, name) : name;
if (showExt)
path += ext;
filesBox.AppendText(path + Environment.NewLine);
list.Add(path);
}
return list;
}
private List<string> GetDirectoryList(string searchPath)
{
var list = new List<string>();
var showPath = showFullPathsBox.Checked;
if (showPath)
{
list.AddRange(Directory.GetDirectories(searchPath));
}
else
{
foreach (var dir in Directory.GetDirectories(searchPath))
{
var name = Path.GetFileNameWithoutExtension(dir);
list.Add(name);
}
}
return list;
}
private void showFullPathsBox_CheckedChanged(object sender, EventArgs e)
@@ -89,5 +130,10 @@ namespace ListFiles
updateTimer.Stop();
updateTimer.Start();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
UpdateList();
}
}
}

View File

@@ -13,6 +13,23 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>\\SERVER4\Data\Software\ListFiles\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Background</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<PublisherName>Rogers Engineering</PublisherName>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
@@ -33,6 +50,42 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>FE39E3AAE22D662C6E86BA34AA85E4E6CEBF01EC</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>ListFiles_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -66,6 +119,8 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="ListFiles_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -76,6 +131,23 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
<Visible>False</Visible>
<ProductName>Windows Installer 4.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>