method ExDataObjectFiles.Add (FileName as String)

Adds a filename to the Files collection

TypeDescription
FileName as String A string expression that indicates a filename.

Use Add method to add your files to the drag and drop data source. Use the Files property to retrieve the filenames if the format of data is exCFiles. The OLEDragDrop event notifies your application that the user drags some data on the control. The control fires the OLEStartDrag event to notify your application that the user stars dragging files. Use the Get property to retrieve the selected items. Use the FullName property to retrieve the full name of the file. You can use the RegisterClipboardFormat API  function to register a new clipboard format. This format can then be used as a valid clipboard format. Use the SingleSel property to allow multiple selection in the control.

The following VB sample starts dragging the selected files: 

Private Sub ExFileView1_OLEStartDrag(ByVal Data As ExDataObject, AllowedEffects As Long)
    Data.Files.Clear
    With ExFileView1.Get(SelItems)
        Dim i As Long
        For i = 0 To .Count - 1
         Data.Files.Add .Item(i).FullName
        Next
    End With
    If (Data.Files.Count > 0) Then
        AllowedEffects = 1
        Data.SetData , exCFFiles
    End If
End Sub

The following C++ sample starts dragging the selected files: 

#import <exfilevw.dll>
void OnOLEStartDragExfileview1(LPDISPATCH Data, long FAR* AllowedEffects) 
{
	EXFILEVIEWLib::IExDataObjectPtr spData( Data );
	spData->Clear();
	CFiles files = m_fileview.GetGet( 0 /*SelItems*/ );
	for ( long i = 0; i < files.GetCount(); i++ )
		spData->Files->Add( files.GetItem( COleVariant( i ) ).GetFullName().operator LPCTSTR() );
	if ( spData->Files->Count > 0 )
	{
		*AllowedEffects = 1; /*exOLEDropEffectCopy*/
		spData->SetData( vtMissing, COleVariant( long(15) ) ); /*exCFFiles*/
	}
}

The C++ requires #import <exfilevw.dll> to import definitions for ExDataObject and ExDataObjectFiles objects. The #import <exfilevw.dll> generates the EXFILEVIEWLib namespace. If the exfilevw.dll file is located in other directory than system folder, the correct path should be provided, else a compiler error occurs.

The following VB.NET sample starts dragging the selected files:

Private Sub AxExFileView1_OLEStartDrag(ByVal sender As Object, ByVal e As AxEXFILEVIEWLib._IExFileViewEvents_OLEStartDragEvent) Handles AxExFileView1.OLEStartDrag
    e.data.Files.Clear()
    With AxExFileView1.get_Get(EXFILEVIEWLib.TypeEnum.SelItems)
        Dim i As Integer
        For i = 0 To .Count - 1
            e.data.Files.Add(.Item(i).FullName())
        Next
    End With
    If (e.data.Files.Count > 0) Then
        e.allowedEffects = 1
        e.data.SetData(, EXFILEVIEWLib.exClipboardFormatEnum.exCFFiles)
    End If
End Sub

The following C# sample starts dragging the selected files:

private void axExFileView1_OLEStartDrag(object sender, AxEXFILEVIEWLib._IExFileViewEvents_OLEStartDragEvent e)
{
	e.data.Files.Clear();
	EXFILEVIEWLib.Files files = axExFileView1.get_Get(EXFILEVIEWLib.TypeEnum.SelItems);
	for ( int i = 0 ; i < files.Count; i++ )
		e.data.Files.Add(files[i].FullName);
	if (e.data.Files.Count > 0)
	{
		e.allowedEffects = 1;
		e.data.SetData(null, EXFILEVIEWLib.exClipboardFormatEnum.exCFFiles);
	}
}

The following VFP sample starts dragging the selected files:

*** ActiveX Control Event ***
LPARAMETERS data, allowedeffects

Data.Files.Clear
With thisform.ExFileView1.Get(0) && SelItems
    local i
    For i = 0 To .Count - 1
     data.Files.Add(.Item(i).FullName)
    Next
EndWith
If (Data.Files.Count > 0) Then
    AllowedEffects = 1
    data.SetData( , 15) && exCFFiles
EndIf