Path problem

I'm trying to select a media file from a filebox and play it. If the file is in the same directory as my program then this works.

FilenameTxt.Text = File1.FileName
FileName = FilenameTxt.Text
Play_MM

but when I modofy the code like this so it should work with files other than in my directory, It does not work

FilenameTxt.Text = File1.Path & "" & File1.FileName
FileName = FilenameTxt.Text
Play_MM

I put it in the text box so I can see how it assembles the name and everything looks correct, but it does not work.
Any ideas what could be wrong with teh path?
Play_MM is below

Public Function Play_MM()
mciSendString "Close MM", 0, 0, 0
Last$ = Mainform.hwnd & " Style " & &H40000000
ToDo$ = "open " & FileName & " Alias MM parent " & Last$
i = mciSendString(ToDo$, 0&, 0, 0)
i = mciSendString("put MM window at 16 10 124 120", 0&, 0, 0)
i = mciSendString("play MM", 0&, 0, 0)
End Function

Thanks Ringo

Comments

  • : I'm trying to select a media file from a filebox and play it. If the file is in the same directory as my program then this works.
    :
    : FilenameTxt.Text = File1.FileName
    : FileName = FilenameTxt.Text
    : Play_MM
    :
    : but when I modofy the code like this so it should work with files other than in my directory, It does not work
    :
    : FilenameTxt.Text = File1.Path & "" & File1.FileName
    : FileName = FilenameTxt.Text
    : Play_MM
    :
    : I put it in the text box so I can see how it assembles the name and everything looks correct, but it does not work.
    : Any ideas what could be wrong with teh path?
    : Play_MM is below
    :
    : Public Function Play_MM()
    : mciSendString "Close MM", 0, 0, 0
    : Last$ = Mainform.hwnd & " Style " & &H40000000
    : ToDo$ = "open " & FileName & " Alias MM parent " & Last$
    : i = mciSendString(ToDo$, 0&, 0, 0)
    : i = mciSendString("put MM window at 16 10 124 120", 0&, 0, 0)
    : i = mciSendString("play MM", 0&, 0, 0)
    : End Function
    :
    : Thanks Ringo
    :

    There are two properties: FileName and FileTitle.
    FileName: the full path to the file
    FileTitle: the name of the file, without the path

    So, to play the file selected:

    ToDo$ = "open " & File1.FileName & "..."

    In VB.NET only FileName is available for OpenFileDialog... But in VB6 both properties are available.

    (There is no property called File1.Path is there?!)
    Greets...
    Richard

  • : : I'm trying to select a media file from a filebox and play it. If the file is in the same directory as my program then this works.
    : :
    : : FilenameTxt.Text = File1.FileName
    : : FileName = FilenameTxt.Text
    : : Play_MM
    : :
    : : but when I modofy the code like this so it should work with files other than in my directory, It does not work
    : :
    : : FilenameTxt.Text = File1.Path & "" & File1.FileName
    : : FileName = FilenameTxt.Text
    : : Play_MM
    : :
    : : I put it in the text box so I can see how it assembles the name and everything looks correct, but it does not work.
    : : Any ideas what could be wrong with teh path?
    : : Play_MM is below
    : :
    : : Public Function Play_MM()
    : : mciSendString "Close MM", 0, 0, 0
    : : Last$ = Mainform.hwnd & " Style " & &H40000000
    : : ToDo$ = "open " & FileName & " Alias MM parent " & Last$
    : : i = mciSendString(ToDo$, 0&, 0, 0)
    : : i = mciSendString("put MM window at 16 10 124 120", 0&, 0, 0)
    : : i = mciSendString("play MM", 0&, 0, 0)
    : : End Function
    : :
    : : Thanks Ringo
    : :
    :
    : There are two properties: FileName and FileTitle.
    : FileName: the full path to the file
    : FileTitle: the name of the file, without the path
    :
    : So, to play the file selected:
    :
    : ToDo$ = "open " & File1.FileName & "..."
    :
    : In VB.NET only FileName is available for OpenFileDialog... But in VB6 both properties are available.
    :
    : (There is no property called File1.Path is there?!)
    : Greets...
    : Richard
    :
    I guess I should have said I'm using VB6, so there is no filetitle that I know of. File1.Path is there and it returns what looks correct. That is why I put it in teh textbox then pass the contents of teh textbox to mcisendstring.
    FOr example, this is the contents of teh textbox when I navigate to a file
    c:Documents and SettingsOwnerDesktopfunny videoscat_in_a_fan.wmv

    which does not work
    but If I don't use teh path property and and access a file in my program directory so that the text box looks like this

    cat_in_a_fan.wmv
    then it works. Could it have somethign to do with spaces in teh path?
    Ringo


  • : : : I'm trying to select a media file from a filebox and play it. If the file is in the same directory as my program then this works.
    : : :
    : : : FilenameTxt.Text = File1.FileName
    : : : FileName = FilenameTxt.Text
    : : : Play_MM
    : : :
    : : : but when I modofy the code like this so it should work with files other than in my directory, It does not work
    : : :
    : : : FilenameTxt.Text = File1.Path & "" & File1.FileName
    : : : FileName = FilenameTxt.Text
    : : : Play_MM
    : : :
    : : : I put it in the text box so I can see how it assembles the name and everything looks correct, but it does not work.
    : : : Any ideas what could be wrong with teh path?
    : : : Play_MM is below
    : : :
    : : : Public Function Play_MM()
    : : : mciSendString "Close MM", 0, 0, 0
    : : : Last$ = Mainform.hwnd & " Style " & &H40000000
    : : : ToDo$ = "open " & FileName & " Alias MM parent " & Last$
    : : : i = mciSendString(ToDo$, 0&, 0, 0)
    : : : i = mciSendString("put MM window at 16 10 124 120", 0&, 0, 0)
    : : : i = mciSendString("play MM", 0&, 0, 0)
    : : : End Function
    : : :
    : : : Thanks Ringo
    : : :
    : :
    : : There are two properties: FileName and FileTitle.
    : : FileName: the full path to the file
    : : FileTitle: the name of the file, without the path
    : :
    : : So, to play the file selected:
    : :
    : : ToDo$ = "open " & File1.FileName & "..."
    : :
    : : In VB.NET only FileName is available for OpenFileDialog... But in VB6 both properties are available.
    : :
    : : (There is no property called File1.Path is there?!)
    : : Greets...
    : : Richard
    : :
    : I guess I should have said I'm using VB6, so there is no filetitle that I know of. File1.Path is there and it returns what looks correct. That is why I put it in teh textbox then pass the contents of teh textbox to mcisendstring.
    : FOr example, this is the contents of teh textbox when I navigate to a file
    : c:Documents and SettingsOwnerDesktopfunny videoscat_in_a_fan.wmv
    :
    : which does not work
    : but If I don't use teh path property and and access a file in my program directory so that the text box looks like this
    :
    : cat_in_a_fan.wmv
    : then it works. Could it have somethign to do with spaces in teh path?
    : Ringo
    :
    :

    Ok so it is the spaces in the path. A path like F: estfile.wmv works fine, so do I get around this problem?
    Ringo



  • : Ok so it is the spaces in the path. A path like F: estfile.wmv works fine, so do I get around this problem?
    : Ringo

    You could try getting the short path name, and build your path that way... from the API Guide
    [code]Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" _
    (ByVal lpszLongPath As String, ByVal lpszShortPath As String, _
    ByVal lBuffer As Long) As Long

    Public Function GetShortPath(strFileName As String) As String

    Dim lngRes As Long, strPath As String
    'Create a buffer
    strPath = String$(165, 0)
    'retrieve the short pathname
    lngRes = GetShortPathName(strFileName, strPath, 164)
    'remove all unnecessary chr$(0)'s
    GetShortPath = Left$(strPath, lngRes)
    End Function

    Private Sub Form_Load()
    MsgBox GetShortPath("c:Program Files")
    End Sub[/code]
  • [b][red]This message was edited by BitByBit_Thor at 2005-8-7 12:59:42[/red][/b][hr]
    I could hardly believe that VB6 and it's controls would ever need Short file names!

    Let me ask it more clearly: What is the typename of the control of File1?

    Greets...
    Richard



  • : [b][red]This message was edited by BitByBit_Thor at 2005-8-7 12:59:42[/red][/b][hr]
    : I could hardly believe that VB6 and it's controls would ever need Short file names!
    :
    : Let me ask it more clearly: What is the typename of the control of File1?
    :
    : Greets...
    : Richard
    :
    :
    :
    :
    Richard,

    File1 is a FileListBox control, not a CommonDialog control. The control itself doesn't need short path. It is the MM subsystem that needs it, becuase its command parameter separator is a space, and if the path contains a space ... you can imagine what happens. Something like DOS.

  • : Richard,
    :
    : File1 is a FileListBox control, not a CommonDialog control.

    So much could have been spared me if he had just answered that question :-)

    :The control itself doesn't need short path. It is the MM subsystem that needs it, becuase its command parameter separator is a space, and if the path contains a space ... you can imagine what happens. Something like DOS.
    :

    Then your solution should definitely work...


    Greets...
    Richard

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories