Skip to content

Commit

Permalink
- Converted projects to .NET 4.5
Browse files Browse the repository at this point in the history
- added some threads for speed optimization
- major code reorganization (preparation for next  step)
- other small fixes
  • Loading branch information
DimitarCC committed Sep 17, 2013
1 parent 3672883 commit 31338a3
Show file tree
Hide file tree
Showing 33 changed files with 6,763 additions and 3,167 deletions.
4 changes: 2 additions & 2 deletions BExplorer/BetterExplorer/ArchiveView/ArchiveDetailView.cs
Expand Up @@ -31,7 +31,7 @@ public ArchiveDetailView(string pathIconLibrary, string pathArchive)
//_iconReader.ReadIcons(pathIconLibrary).ForEach(o => archiveTree.ImageList.Images.Add(o.Icon));
WindowsHelper.WindowsAPI.SetWindowTheme(lvArchiveDetails.Handle, "Explorer", null);
SysImageListHelper.SetListViewImageList(lvArchiveDetails, lst, false);
SevenZipExtractor.SetLibraryPath("7z.dll");
SevenZipExtractor.SetLibraryPath(IntPtr.Size == 8 ? "7z64.dll" : "7z32.dll");
_pathArchive = pathArchive;

Shown += ShowArchiveContent;
Expand Down Expand Up @@ -201,7 +201,7 @@ private void btn_checkarchive_Click(object sender, EventArgs e)

private void lvArchiveDetails_ItemActivate(object sender, EventArgs e)
{
IList<ArchiveFileInfo> archiveinfos = (sender as ListView).Tag as IList<ArchiveFileInfo>;
IList<ArchiveFileInfo> archiveinfos = lvArchiveDetails.Tag as IList<ArchiveFileInfo>;
List<ArchiveFileInfo> arhiveinfoList = new List<ArchiveFileInfo>();
if (SelectedItem.SubItems[1].Text == "Folder")
{
Expand Down
11 changes: 10 additions & 1 deletion BExplorer/BetterExplorer/BetterExplorer.csproj
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BetterExplorer</RootNamespace>
<AssemblyName>BetterExplorer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -51,6 +51,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseVSHostingProcess>false</UseVSHostingProcess>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -63,6 +64,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
Expand All @@ -85,6 +87,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -96,6 +99,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
Expand All @@ -106,6 +110,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Expand All @@ -117,6 +122,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AeroWizard">
Expand Down Expand Up @@ -217,6 +223,8 @@
<Compile Include="MessageReceiver.Designer.cs">
<DependentUpon>MessageReceiver.cs</DependentUpon>
</Compile>
<Compile Include="MFTScanning\NtfsUsnJournal.cs" />
<Compile Include="MFTScanning\Win32Api.cs" />
<Compile Include="MountIso.xaml.cs">
<DependentUpon>MountIso.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -660,6 +668,7 @@
<EmbeddedResource Include="Updater\UpdateWizard.resx">
<DependentUpon>UpdateWizard.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="app.manifest" />
<None Include="Images\jsdm32.pdn" />
<None Include="NLog.config">
Expand Down
42 changes: 37 additions & 5 deletions BExplorer/BetterExplorer/FolderSizeWindow.xaml.cs
Expand Up @@ -21,6 +21,7 @@
using System.Globalization;
using Fluent;
using System.Windows.Interop;
using System.Threading.Tasks;

namespace BetterExplorer
{
Expand Down Expand Up @@ -184,12 +185,15 @@ private long RecurseDirectory(string directory, int level, out int files, out in

// please note that the following line won't work if you try this on a network folder, like \\Machine\C$
// simply remove the \\?\ part in this case or use \\?\UNC\ prefix
findHandle = FindFirstFile(@"\\?\" + directory + @"\*", out findData);
findHandle = FindFirstFile(String.Format(@"\\?\{0}\*", directory), out findData);
if (findHandle != INVALID_HANDLE_VALUE)
{

do
{
if (bgw.CancellationPending)
break;

if ((findData.dwFileAttributes & FileAttributes.Directory) != 0)
{

Expand Down Expand Up @@ -227,6 +231,24 @@ private long RecurseDirectory(string directory, int level, out int files, out in
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool FindClose(IntPtr hFindFile);

public IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOpt)
{
try
{
var dirFiles = Enumerable.Empty<string>();
if (searchOpt == SearchOption.AllDirectories)
{
dirFiles = Directory.EnumerateDirectories(path)
.SelectMany(x => EnumerateFiles(x, searchPattern, searchOpt));
}
return dirFiles.Concat(Directory.EnumerateFiles(path, searchPattern));
}
catch (UnauthorizedAccessException ex)
{
return Enumerable.Empty<string>();
}
}

void bgw_DoWork(object sender, DoWorkEventArgs e)
{
//FSI = FolderSizeInfoClass.ConstructData(e.Argument.ToString());
Expand All @@ -243,12 +265,12 @@ void bgw_DoWork(object sender, DoWorkEventArgs e)
progressBar1.Maximum = diri.Count();
}));

foreach (DirectoryInfo item in diri)
Parallel.ForEach(diri, (item, state) =>
{
if ((sender as BackgroundWorker).CancellationPending)
{
break;
state.Break();
}
FolderSizeInfoClass fsi = new FolderSizeInfoClass();
fsi.FolderSizeLoc = item.Name;
Expand Down Expand Up @@ -277,14 +299,23 @@ void bgw_DoWork(object sender, DoWorkEventArgs e)
//}
int ii = 0;
int iff = 0;
retsize = RecurseDirectory(item.FullName, -1, out ii, out iff);
try
{
retsize = RecurseDirectory(item.FullName, -1, out ii, out iff);
}
catch (Exception)
{
}
fsi.FSize = retsize;
FSI.Add(fsi);
(sender as BackgroundWorker).ReportProgress(i++);
}
});
shol.Clear();
GC.Collect();
GC.WaitForPendingFinalizers();
Expand All @@ -294,6 +325,7 @@ void bgw_DoWork(object sender, DoWorkEventArgs e)
}
}


private long GetFolderSize(string dir, bool includesubdirs)
{
shol.Clear();
Expand Down

0 comments on commit 31338a3

Please sign in to comment.