Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO: Prevent certain files from being dropped in FileView

 
Subscribe to the RSS feed for this forum  Forum Index -> FileView.Net/WPF
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Sat Apr 25, 2009 8:34 am    Post subject: HOWTO: Prevent certain files from being dropped in FileView

To prevent certain files from being dropped in FileView, use the following code in the FileViewDragOver event:
[C#]
Code:
private void fileView_FileViewDragOver(object sender, LogicNP.FileViewControl.FileViewDragOverEventArgs e)
{
    // exit if no data
    if (e.Data == null)
        return;

    // retrieve files being dragged
    string[] draggedFiles = (String[])e.Data.GetData(DataFormats.FileDrop);

    // get first file in array
    string firstfile = draggedFiles[0];

    // convert to lowercase for comparison
    firstfile = firstfile.ToLower();

    // if files is from "c:\" drive, dont allow it to be dropped
    if (firstfile.IndexOf("c:\\") != -1)
        e.Effects = DragDropEffects.None;
}

[VB.Net]
Code:
Private Sub fileView_FileViewDragOver(ByVal sender As System.Object, ByVal e As LogicNP.FileViewControl.FileViewDragOverEventArgs) Handles fileView.FileViewDragOver
' exit if no data
If (e.Data Is Nothing = True) Then
    Return
End If

' retrieve files being dragged
Dim draggedFiles As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())

' get first file in array
Dim firstfile As String = draggedFiles(0)

' convert to lowercase for comparison
firstfile = firstfile.ToLower()

' if files is from "c:\" drive, dont allow it to be dropped
If (firstfile.IndexOf("c:\") <> -1) Then
    e.Effects = DragDropEffects.None
End If

End Sub
Back to top
Display posts from previous:   
Forum Index -> FileView.Net/WPF All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group