Initial commit

This commit is contained in:
kawaiizenbo 2025-01-22 11:29:49 -07:00
commit d3d8347a60
20 changed files with 1344 additions and 0 deletions

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BE979188-8383-470B-BA69-202D36152DA7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AFCExplorer</RootNamespace>
<AssemblyName>AFCExplorer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="iMobileDevice-net, Version=1.3.0.0, Culture=neutral, PublicKeyToken=040ae19651fac98a, processorArchitecture=MSIL">
<HintPath>..\packages\iMobileDevice-net.1.3.17\lib\net45\iMobileDevice-net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="GenericSingleInputWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AFCFileType.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="GenericSingleInputWindow.xaml.cs">
<DependentUpon>GenericSingleInputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets" Condition="Exists('..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets'))" />
</Target>
</Project>

View file

@ -0,0 +1,21 @@
using System;
namespace AFCExplorer
{
public class AFCFileType
{
public string Name { get; set; }
public string Type { get; set; }
public string Modified { get; set; }
public string Size { get; set; }
public AFCFileType(string name, string type, string modified, string size)
{
Name = name;
Type = type;
Modified = modified;
Size = size;
if (Type == "Directory") Size = "";
}
}
}

6
AFCExplorer/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

9
AFCExplorer/App.xaml Normal file
View file

@ -0,0 +1,9 @@
<Application x:Class="AFCExplorer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AFCExplorer"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
AFCExplorer/App.xaml.cs Normal file
View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace AFCExplorer
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View file

@ -0,0 +1,15 @@
<Window x:Class="AFCExplorer.GenericSingleInputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AFCExplorer"
mc:Ignorable="d"
Title="GenericSingleInputWindow" Height="105" Width="250" ResizeMode="NoResize">
<Grid>
<TextBox x:Name="TextBox" Margin="10,10,10,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
<Button x:Name="OKButton" Content="OK" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="20" Width="50" Grid.Column="1" Click="OKButton_Click"/>
<Button x:Name="CancelButton" Content="Cancel" HorizontalAlignment="Right" Margin="0,0,65,10" VerticalAlignment="Bottom" Width="50" Height="20" Grid.Column="1" Click="CancelButton_Click"/>
</Grid>
</Window>

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace AFCExplorer
{
public partial class GenericSingleInputWindow : Window
{
public DialogResult result;
public GenericSingleInputWindow()
{
InitializeComponent();
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
result = System.Windows.Forms.DialogResult.OK;
Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
result = System.Windows.Forms.DialogResult.Cancel;
Close();
}
}
}

View file

@ -0,0 +1,38 @@
<Window x:Name="window" x:Class="AFCExplorer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AFCExplorer"
mc:Ignorable="d"
Title="AFCExplorer (loading...)" Height="600" Width="800" Loaded="Event_window_Loaded">
<Grid>
<Button x:Name="RefreshButton" Content="Refresh" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="RefreshButton_Click"/>
<Button x:Name="HomeButton" Content="Home" HorizontalAlignment="Left" Margin="65,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="HomeButton_Click"/>
<Button x:Name="GoUpButton" Content="Go Up" HorizontalAlignment="Left" Margin="120,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="GoUpButton_Click"/>
<TextBox x:Name="PathTextBox" Margin="175,10,40,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="25" FontSize="16"/>
<Button x:Name="GoButton" Content="Go" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" Width="25" Height="25" Click="GoButton_Click"/>
<Grid VerticalAlignment="Bottom" Height="24">
<Grid.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.MenuBarColorKey}}"/>
</Grid.Background>
<Label x:Name="StatusLabel" Content="Waiting for device..." FontSize="11" />
</Grid>
<ListView x:Name="DirectoryItems" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="10,70,10,29" MouseDoubleClick="DirectoryItems_MouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="Date Modified" DisplayMemberBinding="{Binding Modified}"/>
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding Type}"/>
<GridViewColumn Header="Size" DisplayMemberBinding="{Binding Size}"/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="UploadFileButton" Content="Upload File" HorizontalAlignment="Left" Margin="10,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="UploadFileButton_Click"/>
<Button x:Name="DownloadFileButton" Content="Download File" HorizontalAlignment="Left" Margin="115,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="DownloadFileButton_Click"/>
<Button x:Name="DeleteButton" Content="Delete Selected" HorizontalAlignment="Left" Margin="220,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="DeleteButton_Click"/>
<Button x:Name="MakeDirectoryButton" Content="Make Directory" HorizontalAlignment="Left" Margin="325,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="MakeDirectoryButton_Click"/>
<Button x:Name="ConnectAFC2Button" Content="Enable AFC2" HorizontalAlignment="Right" Margin="0,40,10,0" VerticalAlignment="Top" Width="100" Height="25" Click="ConnectAFC2Button_Click"/>
</Grid>
</Window>

View file

@ -0,0 +1,363 @@
using iMobileDevice;
using iMobileDevice.Afc;
using iMobileDevice.iDevice;
using iMobileDevice.Lockdown;
using iMobileDevice.Plist;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Timers;
using System.Windows;
using System.Windows.Input;
namespace AFCExplorer
{
public partial class MainWindow : Window
{
private readonly IiDeviceApi idevice = LibiMobileDevice.Instance.iDevice;
private readonly ILockdownApi lockdown = LibiMobileDevice.Instance.Lockdown;
public static IAfcApi afc = LibiMobileDevice.Instance.Afc;
private iDeviceHandle deviceHandle;
private LockdownClientHandle lockdownHandle;
public static LockdownServiceDescriptorHandle lockdownServiceHandle;
public static AfcClientHandle afcHandle;
private string deviceType;
private string deviceName;
private string deviceVersion;
private string deviceUDID = "";
private bool gotDeviceInfo;
private readonly Timer deviceDetectorTimer;
string path = "/";
bool afc2 = false;
public MainWindow()
{
InitializeComponent();
NativeLibraries.Load();
deviceDetectorTimer = new Timer
{
Interval = 1000
};
deviceDetectorTimer.Elapsed += Event_deviceDetectorTimer_Tick;
}
private void ReadDirectory()
{
try
{
if (!path.EndsWith("/")) throw new Exception();
afc.afc_read_directory(afcHandle, path, out ReadOnlyCollection<string> tempFilesList).ThrowOnError();
List<AFCFileType> afcDirectory = new List<AFCFileType>();
foreach (string fn in tempFilesList)
{
if (fn == "." || fn == "..") continue;
afc.afc_get_file_info(afcHandle, path + fn, out ReadOnlyCollection<string> fileInfo).ThrowOnError();
string readableSize = FormatBytes(ulong.Parse(fileInfo[1]));
string readableType = fileInfo[7] == "S_IFDIR" ? "Directory" : "File";
int unixSeconds = (int)(((long.Parse(fileInfo[9]) / 1000) / 1000) / 1000);
string readableTime = DateTimeOffset.FromUnixTimeSeconds(unixSeconds).DateTime.ToString();
afcDirectory.Add(new AFCFileType(fn, readableType, readableTime, readableSize));
}
DirectoryItems.ItemsSource = afcDirectory;
PathTextBox.Text = path;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
path = "/";
if (afc2) path = "/private/var/mobile/Media/";
ReadDirectory();
}
}
private void ChangeTransportControlState(bool enabled)
{
RefreshButton.IsEnabled = enabled;
HomeButton.IsEnabled = enabled;
PathTextBox.IsEnabled = enabled;
GoButton.IsEnabled = enabled;
DownloadFileButton.IsEnabled = enabled;
UploadFileButton.IsEnabled = enabled;
MakeDirectoryButton.IsEnabled = enabled;
DeleteButton.IsEnabled = enabled;
ConnectAFC2Button.IsEnabled = enabled;
GoUpButton.IsEnabled = enabled;
if (!enabled) DirectoryItems.ItemsSource = null;
}
private void Event_window_Loaded(object sender, RoutedEventArgs e)
{
ChangeTransportControlState(false);
deviceDetectorTimer.Start();
}
private void Event_deviceDetectorTimer_Tick(object sender, EventArgs e)
{
int count = 0;
if (idevice.idevice_get_device_list(out ReadOnlyCollection<string> udids, ref count) == iDeviceError.NoDevice || count == 0)
{
// found nothing
deviceUDID = "";
Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate ()
{
window.Title = "AFCExplorer (No Device)";
}));
if (gotDeviceInfo)
{
// device was connected and now it isnt, let user know
Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate ()
{
ChangeTransportControlState(false);
StatusLabel.Content = "Device disconnected.";
ConnectAFC2Button.Content = "Enable AFC2";
PathTextBox.Text = "/";
}));
gotDeviceInfo = false;
afc2 = false;
path = "/";
}
}
else
{
if (!gotDeviceInfo)
{
try
{
Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate ()
{
StatusLabel.Content = "Found device, attempting to connect.";
}));
idevice.idevice_new(out deviceHandle, udids[0]).ThrowOnError();
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "AFCExplorer").ThrowOnError();
// make afc connection
lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc", out lockdownServiceHandle);
lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle);
// get device info
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductVersion", out PlistHandle temp).ThrowOnError();
temp.Api.Plist.plist_get_string_val(temp, out deviceVersion);
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductType", out temp).ThrowOnError();
temp.Api.Plist.plist_get_string_val(temp, out deviceType);
temp.Dispose();
deviceUDID = udids[0];
Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate ()
{
window.Title = $"AFCExplorer ({deviceName}, {deviceType}, iOS {deviceVersion})";
StatusLabel.Content = "Connected to device.";
PathTextBox.Text = path;
ChangeTransportControlState(true);
ReadDirectory();
}));
gotDeviceInfo = true;
}
catch (Exception ex)
{
// fucked it up in some way
MessageBox.Show(ex.Message);
deviceUDID = "";
Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate ()
{
window.Title = "AFCExplorer (No Device)";
StatusLabel.Content = "Failed to connect to device.";
ChangeTransportControlState(false);
}));
gotDeviceInfo = false; // never should matter but just in case
}
}
}
}
private void GoButton_Click(object sender, RoutedEventArgs e)
{
path = PathTextBox.Text;
ReadDirectory();
}
private void HomeButton_Click(object sender, RoutedEventArgs e)
{
// these go to the same place
path = "/";
if (afc2) path = "/private/var/mobile/Media/";
ReadDirectory();
}
private void RefreshButton_Click(object sender, RoutedEventArgs e)
{
ReadDirectory();
}
private void ConnectAFC2Button_Click(object sender, RoutedEventArgs e)
{
// disable afc2 if already enabled
if (afc2)
{
lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc", out lockdownServiceHandle).ThrowOnError();
lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle).ThrowOnError();
afc2 = false;
ConnectAFC2Button.Content = "Enable AFC2";
path = "/";
ReadDirectory();
}
else
{
try
{
lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc2", out lockdownServiceHandle).ThrowOnError();
lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle).ThrowOnError();
afc2 = true;
ConnectAFC2Button.Content = "Disable AFC2";
path = "/private/var/mobile/Media/";
ReadDirectory();
}
catch (Exception)
{
MessageBox.Show("AFC2 Connection failed!\nBe sure your device is jailbroken and has the Apple File Conduit 2 tweak installed.");
afc2 = false;
}
}
}
private void MakeDirectoryButton_Click(object sender, RoutedEventArgs e)
{
GenericSingleInputWindow inputDialog = new GenericSingleInputWindow();
inputDialog.Title = "Name of directory.";
inputDialog.TextBox.Text = "New Folder";
inputDialog.ShowDialog();
if (inputDialog.result == System.Windows.Forms.DialogResult.Cancel) return;
afc.afc_make_directory(afcHandle, path + inputDialog.TextBox.Text);
ReadDirectory();
}
private void UploadFileButton_Click(object sender, RoutedEventArgs e)
{
var openAfcUploadFile = new Microsoft.Win32.OpenFileDialog();
openAfcUploadFile.ShowDialog();
if (openAfcUploadFile.FileName == "") return;
string afcUploadFilePath = openAfcUploadFile.FileName;
string afcUploadFileName = afcUploadFilePath.Split('\\').Last();
ulong handle = 0UL;
afc.afc_file_open(afcHandle, path + "/" + afcUploadFileName, AfcFileMode.FopenRw, ref handle);
byte[] array = File.ReadAllBytes(afcUploadFilePath);
uint bytesWritten = 0U;
afc.afc_file_write(afcHandle, handle, array, (uint)array.Length, ref bytesWritten);
afc.afc_file_close(afcHandle, handle);
ReadDirectory();
}
private void DownloadFileButton_Click(object sender, RoutedEventArgs e)
{
var saveAfcFile = new Microsoft.Win32.SaveFileDialog
{
FileName = ((AFCFileType)DirectoryItems.SelectedItem).Name
};
saveAfcFile.ShowDialog();
string afcSaveFilePath = saveAfcFile.FileName;
string afcFilePath = path + ((AFCFileType)DirectoryItems.SelectedItem).Name;
afc.afc_get_file_info(afcHandle, afcFilePath, out ReadOnlyCollection<string> infoListr);
List<string> infoList = new List<string>(infoListr.ToArray());
long fileSize = Convert.ToInt64(infoList[infoList.FindIndex(x => x == "st_size") + 1]);
ulong fileHandle = 0;
afc.afc_file_open(afcHandle, afcFilePath, AfcFileMode.FopenRdonly, ref fileHandle);
FileStream fileStream = File.Create(afcSaveFilePath);
const int bufferSize = 4194304;
for (int i = 0; i < fileSize / bufferSize + 1; i++)
{
uint bytesRead = 0;
long remainder = fileSize - i * bufferSize;
int currBufferSize = remainder >= bufferSize ? bufferSize : (int)remainder;
byte[] currBuffer = new byte[currBufferSize];
if (afc.afc_file_read(afcHandle, fileHandle, currBuffer, Convert.ToUInt32(currBufferSize), ref bytesRead)
!= AfcError.Success)
{
afc.afc_file_close(afcHandle, fileHandle);
}
fileStream.Write(currBuffer, 0, currBufferSize);
}
fileStream.Close();
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
try
{
afc.afc_remove_path(afcHandle, path + $"/{DirectoryItems.SelectedItem}").ThrowOnError();
ReadDirectory();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Failed to delete item.");
}
}
private void DirectoryItems_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (DirectoryItems.SelectedItem == null) return;
if (((AFCFileType)DirectoryItems.SelectedItem).Type == "File") return;
path += $"{((AFCFileType)DirectoryItems.SelectedItem).Name}/";
ReadDirectory();
}
private void GoUpButton_Click(object sender, RoutedEventArgs e)
{
if (path == "/") return;
path = path.Replace('/' + path.TrimEnd('/').Split('/').Last(), "");
ReadDirectory();
}
public static string FormatBytes(ulong bytes)
{
string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
int i;
double dblSByte = bytes;
for (i = 0; i < Suffix.Length && bytes >= 1000; i++, bytes /= 1000)
{
dblSByte = bytes / 1000.0;
}
return string.Format("{0:0.##} {1}", dblSByte, Suffix[i]);
}
}
}

View file

@ -0,0 +1,52 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AFCExplorer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AFCExplorer")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AFCExplorer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AFCExplorer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AFCExplorer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="iMobileDevice-net" version="1.3.17" targetFramework="net45" />
</packages>