Results 1 to 6 of 6

Thread: [RESOLVED] Drag & Drop Get File Properties

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [RESOLVED] Drag & Drop Get File Properties

    I have finally got the drag and drop to work on my form, so the user can drop files on it. I have used the msdn example so i can get the whole filename (path + filename). But how do i get only the filename? (lol.zip) And maybe the path where it is?

    This is my current code:

    Code:
                string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
                int i;
                for (i = 0; i < s.Length; i++)
    so if i write MessageBox.Show(s[i]) it shows the path + filename.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Drag & Drop Get File Properties

    why are you posting c# questions in the vb.net forum?
    do you want the answer in vb?

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Drag & Drop Get File Properties

    Code:
    Dim theFileName As String = IO.Path.GetFileName("your-file-path-here")
    Dim theFolderName As String = IO.Path.GetDirectoryName("your-file-path-here")
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Drag & Drop Get File Properties

    try this:

    vb Code:
    1. Dim s() As Object = e.Data.GetData(DataFormats.FileDrop, False)
    2. Dim fi As New IO.FileInfo(s(0))
    3. MsgBox("Path = " & IO.Path.GetDirectoryName(fi.FullName) & Environment.NewLine & "Filename = " & IO.Path.GetFileName(fi.FullName))

  5. #5

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Drag & Drop Get File Properties

    Sorry i posted wrong, but i guess i can translate that code to C.

  6. #6

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Drag & Drop Get File Properties

    now i converted it and it works, thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width