CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2001
    Posts
    38

    Grabbing Only the FileName from a Common Dialog

    Hi,

    The Following code loads a file from a path chosen using Common dialog 6:

    With cdopen '---->>>>This is the name of the common dialog control object
    '
    .DialogTitle = "Select Movie File/Image to be Imported..."
    .FileName = ""
    .Filter = "Tutorial Files (*.wmv*,*.jpg*)|*.wmv*;*.txt*"
    .ShowOpen


    If Len(.FileName) <> 0 Then

    mstream.LoadFromFile .FileName
    rs.Fields("MM_entity").Value = mstream.Read
    'Update
    rs("MMType_id") = 2
    rs("MM_Caption") = "Test"
    rs.Fields("MM_filename").Value = cdopen.FileName <<<<<<----Help Here
    rs.Update
    End If
    If .FileName = "" Then
    GoTo Command3_Error
    End If

    End With


    After Selecting the file, it gets saved to a DB. As you see, I insert the .FileName value into a Field in the DB. The thing is, I only want to grab the file name. When saving, this code is inserting the whole path as well. Can you guys help me on how to grab only the FileName????

    Thanks,

    Herick


  2. #2
    Join Date
    Aug 1999
    Location
    Bangalore, INDIA
    Posts
    70

    Re: Grabbing Only the FileName from a Common Dialog

    Use
    .FileTitle Instead of .FileName
    Cheers,
    Sharath



  3. #3
    Join Date
    Apr 2001
    Posts
    14

    Re: Grabbing Only the FileName from a Common Dialog

    Herick, I'm writing an app that does the exact same thing. I used the .FileTitle property to get ONLY the filename from the open dialog. Give it a try
    fileName = .cdOpen.FileTitle

    Brian


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

Featured