Current filter:
                                You should refresh the page.
                                Support Center

                                The FileSystemData module provides the FileSystemStoreObject and FileSystemLinkObject classes that implement the IFileData interface for the use with our File Attachments module.
                                FileSystemStoreObject - this class enables you to store uploaded files in a centralized file system location instead of the database. You can configure the file system store location via the static FileSystemDataModule.FileSystemStoreLocation property.
                                FileSystemLinkObject - this class enables you to add soft links to real files instead of saving their contents to the database. Apparently, it is intended for use in Windows Forms applications only.

                                Refer to the following video to see this functionality in action:

                                Steps to implement
                                1. Copy and include the FileSystemData project into your solution and make sure it is built successfully.

                                2. Invoke the Module Designer for the YourSolutionName.Module/Module.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the FileSystemDataModule component into the modules list on the left.
                                3. Define a FileSystemStoreObject or FileSystemLinkObject type properties within your business class as described in the eXpressApp Framework > Task-Based Help > How to: Implement File Data Properties article. Make sure to decorate the container business class with the FileAttachmentAttribute (to provide additional commands for working with files) and also do not miss the Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never) and ImmediatePostData attributes for the new class properties. See the E965.Module\BusinessObjects\FileSystemStoreObjectDemo.xx and E965.Module\BusinessObjects\FileSystemLinkObjectDemo.xx  source files for examples. 

                                4. Make sure you do not override the DevExpress.Persistent.BaseImpl.BaseObject.OidInitializationMode property in your application and related modules, because the OidInitializationMode.AfterConstruction value is necessary for the correct operation of this module (in the example, the required default value is already set in the FileSystemDataModule class of this example module).
                                5. Modify YourSolutionName.Win/WinApplication.xx file to handle the CustomOpenFileWithDefaultProgram event of the DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentsWindowsFormsModule class as shown in the E965.Win\WinApplication.xx file.


                                IMPORTANT NOTES
                                The current version of this example does not support the middle-tier scenario. Refer to the Q476039 ticket for more details.
                                2. If you plan to migrate existing FileData objects from the database to a file system, you can use the techniques described in the eXpressApp Framework > Concepts > Data Manipulation and Business Logic article to create read FileData objects and create new FileSystemStoreObject objects based on their content. Since both classes implement IFileData, you can call their LoadFromStream and SaveToStream methods to copy data. Even though we do not provide a ready example for this migration procedure, we hope that the example below will be helpful for getting started:

                                FileData fd = ObjectSpace.FindObject<FileData>(null); // Use any other IObjectSpace APIs to query required data. FileSystemStoreObject fss = ObjectSpace.CreateObject<FileSystemStoreObject>(); Stream sourceStream = new MemoryStream(); ((IFileData)fd).SaveToStream(sourceStream); sourceStream.Position = 0; ((IFileData)fss).LoadFromStream(fd.FileName, sourceStream); ObjectSpace.CommitChanges();

                                Of course, you can rework this code to use UnitOfWork instead of IObjectSpace.


                                See Also:
                                File Attachments Module Overview
                                Working with links to files instead of storing their contents in the database
                                SQL Server FILESTREAM feature Overview

                                • Roger Gardner 08.02.2012

                                  -How to change FileStoreObject to work With Application server?
                                  -How many files you can store in one folder and the system is not to slow?

                                  Can this sample be upgraded with Application server and multiple folders in File Data Store folder?

                                • Sander Mclean 08.22.2012

                                  Thank you for your example, but could you upgrade this to VB.NET?

                                • Martin Kraeuchi 10.12.2012

                                  I tried to run this example but it crashes.
                                  It occurs a fatal error when I try to append a file after creating a new "Standard File Data Demo" Item. The error occurs at the moment the file select box opens. I didn't found a way to debug it.
                                  Do you have a glue what it could be?

                                  My configuration:
                                  Win7 64BIT, VS2010, v2012 vol 1.7, SQL Server Express 2008 R2

                                  Thanks, Martin

                                • @Roger: I have not yet tested this module with the application server. It is a good idea, though. Thank you for your input, I have added it to my TODO list.

                                  @Sander: It is quite complex a module to rewrite it in VB.NET, as well as maintain two versions later. Even though it is not in my immediate plans, you can either include the C# module project into your VB.NET solution (Visual Studio allows this) or rather use free or paid conversion tools.

                                  @Martin: Thank you for your comment. Hm, it performs perfectly well for me. I also ran functional tests that passed locally. You are probably not using the latest version in this example. It would be great if you could create a separate ticket in the Support Center and attach the eXpressAppFramework.log file with the error details. Thank you in advance!

                                  Sorry for the late reply, guys. In the future, it is better to submit a ticket directly via the link, if you experienced any difficulties with our tools.

                                • ABRAMO ABRAMO 11.21.2013

                                  I'm working with Images in XAF application storing user image file to file system. So I'm using FileSystemStoreObject and It work fine for me. However, I've some problem!

                                  one - I'd like split and save user images in FileData\<mykey1> folder where mykey1 depends by Business Objects instance1,
                                  user images in FileData\<mykey2> folder where mykey2 depends by Business Objects instance2 and so on.
                                  two - I'd like show stored images like Images Slides Control or a link item in grid view to open images.

                                  Do you have any suggestion or example?

                                  Best regards,

                                • Ricardo Granja 01.27.2014

                                  Do vou have an exemple of this as a domain componente?


                                • xaero xy 06.02.2014

                                  Did the "StandardFileDataDemo" store file attachments in database?

                                • @xaero: The StandardFileDataDemo class uses the FileData class that stores files in the database and which is a part of the standard delivery.

                                  In turn, the FileSystemStoreObjectDemo class stores files in the file system with the help of custom IFileData implementations described in this example.

                                • Steve Perks @ NSS 09.19.2014

                                  Hi Dennis, thank you for the code - it works great in my web application (I'm only using the FileSystemStoreObject). I've made a mod to cover the case where the user has previously saved a business object and subsequently reloads it to edit the FileSystemStoreObject property, namely to pick a different file. In this case _tempFileName is not correctly populated and the old file is not deleted when the file is changed and the business object saved.

                                  My solution was to add the following code to FileSystemStoreObject.cs

                                     protected override void OnLoaded()
                                         _tempFileName = this.RealFileName;

                                  Hope this helps others and perhaps you could update your code if you also feel this is a good solution.

                                • Thanks for sharing, Steve. Would you please either record a video showing how to replicate this behavior with the original example or create a functional EasyTest script covering this scenario? This will help me better understand the situation and make changes, if necessary. Thanks in advance! 

                                • Steve Perks @ NSS 09.19.2014

                                  Dennis, how shall I send the video? No attachments in this thread.

                                • Steve Perks @ NSS 09.19.2014

                                  It's ok about sending the video, I've decided to host it for a short while here:

                                • Thanks for your video, Steve. I will take this scenario into account  for future updates.
                                • Genesis Supsup 1 12.30.2015

                                  Does this already work using Application Server? Given the correct credentials, will this concept work with Dropbox (in replacement to File System)?

                                • Hello,

                                  To process your recent post more efficiently, I created a separate ticket on your behalf: T329782: E965 with dropbox. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

                                • Joseph Kellerer 2 02.26.2016
                                  Thank you for providing this code!
                                  It works great.

                                  I have enhanced the FileSystemStoreObject to have a Content property like in the BaseImpl.FileData class:

                                  [NonPersistent] public byte[] Content { get { return File.ReadAllBytes(this.RealFileName); } set { this.TempSourceStream = new MemoryStream(value); } }
                                • CHRIS TSELEBIS 03.16.2016
                                  The deletion is not working correctly on the detailview.  I hit delete, filed is deleted but gets an error message saying "requested objects canot be loaded, because they are abasent in the data store....".  It works fine in the listview.  Please check.
                                • @Chris: Thanks for your feedback. In the meantime, you can remove the DeferredDeletion(false) attribute declaration from the FileSystemStoreObject class as a solution.
                                • CHRIS TSELEBIS 03.17.2016
                                  Dennis,  is it possible to make the textbox(filename) bigger?  I tried to set the width and height on detailview and no success.  Right now it's just using one row and no way to set rowcount for this field.  I want the textbox to be bigger so it's easier for user to drag and drop on detailview.
                                • @Chris: To process your recent post more efficiently, I created a separate ticket on your behalf: T358143: How to set the width and height of the FileData PropertyEditor control. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates. For better tracking, please also use the service to submit new questions regarding this or any other XAF functionality. Thanks for your understanding.

                                • Joseph Kellerer 2 10.20.2016
                                  If I edit an oject which uses an FileSystemStoreObject
                                  change the file name,
                                  the old file remained and was not deleted.

                                  After I changed LoadFromStream method to
                                  void IFileData.LoadFromStream(string fileName, Stream source) { //Dennis: When assigning a new file we need to save the name of the old file to remove it from the store in the future. if (fileName != FileName) // changed, old code was if (string.IsNullOrEmpty(tempFileName)) tempFileName = RealFileName; FileName = fileName; TempSourceStream = source; }

                                  it works.
                                • Hello Joseph,

                                  Thank you for your comment.
                                  We will consider your use case and possibly incorporate the changes you suggested to this example.

                                • Alan Pérez 1 11.26.2016
                                  Hi, I'm using this code, but, i have the error when i want to attach a file > 2 Gb size, how can i remove this limitant?

                                  if (value.Length > (long)int.MaxValue) throw new UserFriendlyException("File is too long");

                                • @Alan: I've created a separate ticket on your behalf (T455721: Increase default attachment size in E965). It has been placed in our processing queue and will be answered shortly.

                                • Fitzroy F. Wright 03.22.2017
                                  I need help figuring out how to tell this module to use the value in Options->Attachments->DefaultDirectory Attribute in Model.xafml in my App.WIn project as the default locations to store attachments in the file System.

                                  Can you help?

                                • @Fitzroy F. Wright:
                                  I've created a separate ticket on your behalf (T495520: E965 - How to read the default directory path from a custom element in the Application Model). It has been placed in our processing queue and will be answered shortly.

                                • Giuseppe Ascione 07.19.2017
                                  Hi Support, this extension support the 1 to N relation?
                                  I have try to add this property to my class:
                                  [Aggregated] [Association("PPM_ProjectPortfolio-PPM_Attachments")] [ImmediatePostData] //[ExpandObjectMembers(ExpandObjectMembers.Never)] public XPCollection<FileSystemStoreObject> Attachments { get { return GetCollection<FileSystemStoreObject>("Attachments"); } }

                                  and the related association un the other class:
                                  protected PPM_ProjectPortfolio pPM_ProjectPortfolio; [Persistent, Association("PPM_ProjectPortfolio-PPM_Attachments")] public PPM_ProjectPortfolio PPM_ProjectPortfolio { get { return pPM_ProjectPortfolio; } set { SetPropertyValue("PPM_ProjectPortfolio", ref pPM_ProjectPortfolio, value); } }
                                  but when i open the detailview and is see the list of attachement, i clic to add and I do not see the browse button. Only the  FileSystemStoreObject like FileName.

                                • @Giuseppe:
                                  I've created a separate ticket on your behalf (T537361: Associations with FileSystemStoreObject from E965). It has been placed in our processing queue and will be answered shortly.
                                  For the future, please use the service to submit new questions regarding this or any other XAF functionality. Thanks for your understanding.

                                Show Implementation Details
                                Select file
                                • FileSystemStoreObject.cs
                                • FileSystemLinkObject.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • 16.2.3 - 17.2.7
                                • 15.2.7 - 16.1.7

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2018 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners