1
0
mirror of synced 2024-11-27 17:00:50 +01:00

Archive fixes for replacing folder.

This commit is contained in:
KillzXGaming 2021-12-28 15:02:38 -05:00
parent 6b14db6ffe
commit 54dce49fdd
2 changed files with 27 additions and 2 deletions

View File

@ -214,6 +214,17 @@ namespace Toolbox.Library
}
}
public static string GetFolderAbsoultePath(TreeNode node, ArchiveRootNodeWrapper rootNode)
{
string nodePath = node.FullPath;
int startIndex = nodePath.IndexOf(rootNode.Text);
if (startIndex > 0)
nodePath = nodePath.Substring(startIndex);
string slash = Path.DirectorySeparatorChar.ToString();
string slashAlt = Path.AltDirectorySeparatorChar.ToString();
return nodePath.Replace(rootNode.Text + slash, string.Empty).Replace(slash ?? "", slashAlt);
}
public static void AddFiles(TreeNode parentNode, ArchiveRootNodeWrapper rootNode, string[] Files)
{

View File

@ -137,6 +137,9 @@ namespace Toolbox.Library
if (ofd.ShowDialog() == DialogResult.OK)
{
if (FileDataStream != null)
FileDataStream = new MemoryStream(File.ReadAllBytes(ofd.FileName));
else
FileData = File.ReadAllBytes(ofd.FileName);
return true;
}
@ -782,7 +785,18 @@ namespace Toolbox.Library
Nodes.Clear();
TreeHelper.AddFiles(this, RootNode, Directory.GetFiles(ofd.SelectedPath));
var proccessedFiles = TreeHelper.ReadFiles(ofd.SelectedPath);
string folderPath = TreeHelper.GetFolderAbsoultePath(this, RootNode);
for (int i = 0; i < proccessedFiles.Count; i++)
{
ArchiveFile.AddFile(new ArchiveFileInfo()
{
FileName = $"{folderPath}/{proccessedFiles[i].Item1}",
FileData = File.ReadAllBytes(proccessedFiles[i].Item2),
});
}
RootNode.FillTreeNodes();
}
}