IFileData Interface
In This Article
Declares members that implement the base functionality of file data objects.
Namespace: DevExpress.Persistent.Base
Assembly: DevExpress.Persistent.Base.v25.1.dll
NuGet Package: DevExpress.Persistent.Base
#Declaration
#Related API Members
The following members return IFileData objects:
#Remarks
If your custom type implements the IFileData
interface, XAF can display objects of this type in the File Data or PDF Viewer property editor.
Tip
Refer to the following file for a sample File
class implementation:
%PROGRAMFILES%\DevExpress 25.
Display FileData.cs code
C#
using System;
using System.ComponentModel;
using System.IO;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
namespace DevExpress.Persistent.BaseImpl.EF {
[DefaultProperty(nameof(FileName))]
public class FileData : BaseObject, IFileData, IEmptyCheckable {
private Byte[] content;
public virtual Int32 Size { get; set; }
public virtual String FileName { get; set; }
public virtual Byte[] Content {
get { return content; }
set {
if(content != value) {
content = value;
Size = content != null ? content.Length : 0;
}
}
}
[Browsable(false)]
public Boolean IsEmpty {
get { return String.IsNullOrEmpty(FileName); }
}
public void LoadFromStream(String fileName, Stream stream) {
FileName = fileName;
Byte[] bytes = new Byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
Content = bytes;
ObjectSpace.SetModified(this);
}
public void SaveToStream(Stream stream) {
if(String.IsNullOrEmpty(FileName)) {
throw new InvalidOperationException();
}
stream.Write(Content, 0, Size);
stream.Flush();
}
public void Clear() {
Content = null;
FileName = "";
ObjectSpace.SetModified(this);
}
public override String ToString() {
return FileName;
}
}
}
To access a full file path, additionally implement the ISupportFullName interface in your class.
- File Data Property Editor (Blazor, WinForms, Web Forms)
- Enable the File Attachments module to display objects that implement the
IFileData
interface in the File Data Property Editor. - PDF Viewer Property Editor (Blazor, WinForms)
- Enable the Office Module and assign
PdfViewerPropertyEditor
to a file data property to display PDF files in the PDF Viewer.
Refer to the following topic for additional details: Use PDF Documents in Business Objects (CTP).
C#
using DevExpress.ExpressApp.Editors;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
// ...
public virtual FileData File { get; set; }
[EditorAlias(EditorAliases.PdfViewerPropertyEditor)]
public FileData ResumeView => File;
See Also