public static HItem PlaceInto(this HItem hItem, string parentName)
        {
            HDirectory parentDirectory = new HDirectory
            {
                Name = parentName
            };

            hItem.Parent = parentDirectory;

            return(parentDirectory);
        }
Esempio n. 2
0
    public static HItem[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        format.Read <int>(ref packetSpan);
        format.Read <int>(ref packetSpan);
        var items = new HItem[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < items.Length; i++)
        {
            items[i] = new HItem(format, ref packetSpan);
        }
        return(items);
    }
        static void Main(string[] args)
        {
            HItem grandfather = new HItem();
            HItem father      = new HItem();
            HItem daughter    = new HItem();

            father.SetParent(grandfather);
            daughter.SetParent(father);

            HItem _SameGrandfather = daughter.GetParent().GetParent();

            Console.WriteLine(_SameGrandfather.childCount);
            Console.Read();
        }
Esempio n. 4
0
        private static void MoveFile(HItem hFile, string destinationDirectory)
        {
            string sourceFilePath = hFile.GetOriginalPath();

            string relativePath = hFile.GetPath()
                                  .TrimStart(Path.DirectorySeparatorChar)
                                  .TrimStart(Path.AltDirectorySeparatorChar);
            string destinationFilePath = Path.Combine(destinationDirectory, relativePath);

            string destinationDirectoryPath = Path.GetDirectoryName(destinationFilePath);

            if (!Directory.Exists(destinationDirectoryPath))
            {
                Directory.CreateDirectory(destinationDirectoryPath);
            }

            File.Move(sourceFilePath, destinationFilePath);

            RemoveParentIfEmpty(sourceFilePath);
        }