Archive fixes for replacing folder.
This commit is contained in:
parent
6b14db6ffe
commit
54dce49fdd
@ -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)
|
||||
{
|
||||
|
@ -137,7 +137,10 @@ namespace Toolbox.Library
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
FileData = File.ReadAllBytes(ofd.FileName);
|
||||
if (FileDataStream != null)
|
||||
FileDataStream = new MemoryStream(File.ReadAllBytes(ofd.FileName));
|
||||
else
|
||||
FileData = File.ReadAllBytes(ofd.FileName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user