DocumentFindUserResource(String) Method |
Gets the UserResource instance with the specified path within this document's user resources.
Namespace: Demo3D.VisualsAssembly: Demo3D.Core (in Demo3D.Core.dll) Version: 19.00.00
Syntaxpublic UserResource FindUserResource(
string localPath
)
Parameters
- localPath String
- The local path of the user resource within this document.
Return Value
UserResourceThe user resource matching the localPath.
Example[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.ReadExactly(bytes);
var tmpFile =
Path.Combine( Path.GetTempPath(), Path.GetFileName(ur.LocalPath) );
File.WriteAllBytes( tmpFile, bytes );
return tmpFile;
}
See Also