Class File
This class represents a generic file entity that can go inside an RO-Crate.
public class File : FileOrDir
- Inheritance
-
File
- Derived
- Inherited Members
Constructors
File()
public File()
File(ROCrate?, string?, JsonObject?, string?, string?, bool, bool)
public File(ROCrate? crate = null, string? identifier = null, JsonObject? properties = null, string? source = null, string? destPath = null, bool fetchRemote = false, bool validateUrl = false)
Parameters
crate
ROCrateidentifier
stringproperties
JsonObjectsource
stringdestPath
stringfetchRemote
boolvalidateUrl
bool
Methods
Deserialize(string, ROCrate)
Create a File from JSON properties.
public static File? Deserialize(string entityJson, ROCrate roCrate)
Parameters
Returns
Serialize()
Convert File to JSON string.
public override string Serialize()
Returns
Write(string)
Write file contents to the specified path. e.g. The root path of an RO-Crate.
If the file is a remote file, and fetchUrl
is set to true
, the file will be downloaded under
"basePath
".
If the file is on disk, it will be copied to a new location under "basePath
".
In either case, the file will be saved to "basePath/Id
"
public override void Write(string basePath)
Parameters
basePath
stringThe path the file will be written to.
Examples
var url = "https://hdruk.github.io/hutch/docs/devs";
var fileName = url.Split('/').Last();
var fileEntity = new Models.File(
new ROCrate(),
source: url,
validateUrl: true,
fetchRemote: true);
fileEntity.Write("myCrate");