?
Solved

Problem with simple file drag and drop. Help??!!

Posted on 2006-05-24
3
Medium Priority
?
220 Views
Last Modified: 2010-04-23
Hi there. I have a very simple form. What I want to do is allow the user to drag an image file into the small form, have the form use the shell command to create a network drive, copy the drag&drop file to the drive, and then close the created drive. Im having a few probs though running the shell command, and also gett the file I need to operate on.

The code I have is simple but close I think. Can anyone tell me what Im doing wrong?

    Private Sub frmDrop_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
        Try
            'Exception thrown here over permissions. How can I execute these commands?
            Shell("Net use n: /Delete", AppWinStyle.Hide, True)
            Shell("net use n: \\192.168.1.1\c$\inetpub\wwwroot\iCentral\banners\advision\  password /USER:administrator", AppWinStyle.Hide, True)

            If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                'Perform a copy command here
'also how do I get the file handle so that I can copy it to the n drive?

            End If


        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            Shell("Net use n: /Delete", AppWinStyle.Hide, True)
        End Try
       
    End Sub

    Private Sub frmDrop_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter


        e.Effect = DragDropEffects.Copy

    End Sub
0
Comment
Question by:Slimshaneey
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16751704
Here is how to get the FileName:

    Private Sub frmDrop_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub frmDrop_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
        Dim a As Array = DirectCast(e.Data.GetData(DataFormats.FileDrop), Array)
        If Not (a Is Nothing) Then
            Dim fileName As String = a.GetValue(0).ToString()

            ' do somethin with fileName...

        End If
    End Sub
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question