Access file fields
Version:
You can use the Sitecore.Data.Fields.FileField class to access data template fields of type File. You can use the Sitecore.Data.Fields.FileField.MediaItem property to access the media item selected in the field. For example, to access the media item referenced by the File field named FileField in the /Sitecore/Content/Home item in the Master database:
You can update the value of a File field by updating the Sitecore.Data.Fields.FileField.MediaID and Sitecore.Data.Fields.FileField.Src attributes. For example, to ensure the File field named FileField in the /Sitecore/Content/Home item in the Master database specifies the /Sitecore/Media Library/Files/Sample media item: