Some fixes for file paths for newly added files

This commit is contained in:
KillzXGaming 2019-07-26 21:30:51 -04:00
parent ded4dae5c1
commit 25aa49cc29
7 changed files with 19 additions and 5 deletions

Binary file not shown.

View file

@ -197,9 +197,16 @@ namespace Toolbox.Library
//Don't add the root file name //Don't add the root file name
if (parentNode.FullPath != string.Empty && !(parentNode is ArchiveRootNodeWrapper)) if (parentNode.FullPath != string.Empty && !(parentNode is ArchiveRootNodeWrapper))
{ {
string FullPath = Path.Combine(parentNode.FullPath, FileName); string nodePath = parentNode.FullPath;
FullPath = FullPath.Substring(FullPath.IndexOf("/", 1) + 1); int startIndex = nodePath.IndexOf(rootNode.Text);
Console.WriteLine($"FullPath {FullPath}"); if (startIndex > 0)
nodePath = nodePath.Substring(startIndex);
string slash = Path.DirectorySeparatorChar.ToString();
string slashAlt = Path.AltDirectorySeparatorChar.ToString();
string SetPath = nodePath.Replace(rootNode.Text + slash, string.Empty).Replace(slash ?? "", slashAlt);
string FullPath = Path.Combine(SetPath, FileName).Replace(slash ?? "", slashAlt);
File.ArchiveFileInfo.FileName = FullPath; File.ArchiveFileInfo.FileName = FullPath;
} }
else else
@ -210,12 +217,12 @@ namespace Toolbox.Library
if (HasAddedFile) if (HasAddedFile)
{ {
parentNode.Nodes.Add(File);
if (parentNode is ArchiveRootNodeWrapper) if (parentNode is ArchiveRootNodeWrapper)
((ArchiveRootNodeWrapper)parentNode).AddFileNode(File); ((ArchiveRootNodeWrapper)parentNode).AddFileNode(File);
if (parentNode is ArchiveFolderNodeWrapper) if (parentNode is ArchiveFolderNodeWrapper)
((ArchiveFolderNodeWrapper)parentNode).RootNode.AddFileNode(File); ((ArchiveFolderNodeWrapper)parentNode).RootNode.AddFileNode(File);
parentNode.Nodes.Add(File);
} }
} }
} }

View file

@ -201,6 +201,13 @@ namespace Toolbox.Library
public void AddFileNode(ArchiveFileWrapper fileWrapper) public void AddFileNode(ArchiveFileWrapper fileWrapper)
{ {
FileNodes.Add(Tuple.Create(fileWrapper.ArchiveFileInfo, (TreeNode)fileWrapper)); FileNodes.Add(Tuple.Create(fileWrapper.ArchiveFileInfo, (TreeNode)fileWrapper));
string FullName = SetFullPath(fileWrapper, this);
if (FullName != string.Empty)
{
Console.WriteLine($"Updating info {FullName}");
fileWrapper.ArchiveFileInfo.FileName = FullName;
}
} }
public ToolStripItem[] GetContextMenuItems() public ToolStripItem[] GetContextMenuItems()

Binary file not shown.

Binary file not shown.