Click or drag to resize

UserResourceLocalPath Property

Gets or sets the name and path of this user resource, relative to the UserResources directory. Never set this property directly, always go through UserResourceLibrary.RenameFile.

Namespace:  Demo3D.Visuals
Assembly:  Demo3D.Core (in Demo3D.Core.dll) Version: 15.0.2.11458
Syntax
C#
public string LocalPath { get; }

Property Value

Type: String
Examples
C#
[Auto] CustomPropertyValue<UserResourceReference> Data;

[Auto] void OnReset(BoxVisual sender) {
    if (!sender.HasProperty("Data")) return;

    var ur = document.FindUserResource(this.Data);
    var localFile = WriteUserResourceToTemporaryFile( ur );

    if (localFile == "") return;

    var dataTable =
        Demo3D.Utilities.DataSourceImporter.ReadDataTableFromTextFile( localFile );

    File.Delete( localFile );

    foreach (var colName in dataTable.Columns) {
        print(colName);
    }
}

string WriteUserResourceToTemporaryFile(UserResource ur) {
    if (ur == null) return "";

    var ins   = ur.GetInputStream(null);
    var len   = ins.Length;
    var bytes = new byte[len];

    ins.Read( bytes, 0, (int)len );

    var tmpFile = 
        Path.Combine( Path.GetTempPath(), Path.GetFileName(ur.LocalPath) );

    File.WriteAllBytes( tmpFile, bytes );

    return tmpFile;
}
See Also