File Info


Node Information
Gets information about the specified file.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Path IN String ONE FALSE FALSE
Size OUT Int64 MULTIPLE FALSE FALSE
ReadableSize OUT String MULTIPLE FALSE FALSE
Name OUT String MULTIPLE FALSE FALSE
Extension OUT String MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.File
{
    [IsNode("Get File Info")]
    public class FileGetInfo : Node
    {
        Port path = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Path");
        Port size = new Port(PortType.OUT, typeof(long), AcceptsLinks.MULTIPLE, "Size");
        Port rsize = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "ReadableSize");
        Port extension = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Extension");
        Port name = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Name");
        public string FilePath
        {
            set { path.Value = value.ToString(); }
            get { return GetRuntimeValue(path); }
        }
        public FileGetInfo()
        {
            this.Name = "File Info";
            size.Value = "0";
            AddPort(path);
            AddPort(size);
            AddPort(rsize);
            AddPort(name);
            AddPort(extension);
            size.Instructions = "init";
            rsize.Instructions = "init";
            extension.Instructions = "init";
            name.Instructions = "init";
            Information = "Gets information about the specified file.";
        }
        public override void UpdateResults()
        {
            string filepath = string.Empty;
            if (path.IsConnected) { filepath = GetValue(path); }
            else { filepath = "@" + q + FilePath + q; }
            size.Instructions = "new System.IO.FileInfo(@" + filepath + ").Length";
            rsize.Instructions = "FileSizeConverter.ConvertSize(new System.IO.FileInfo(@" + filepath + ").Length)";
            name.Instructions = "new System.IO.FileInfo(@" + filepath + ").Extension";
            extension.Instructions = "System.IO.Path.GetFileNameWithoutExtension(@" + filepath + ")";
        }
    }
}