Results 1 to 9 of 9

Thread: Open File Dialog

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    San Diego
    Posts
    14

    Open File Dialog

    When I write a program and use an Open File Dialog Box, and run the program, I cannot access files on my CD-ROM (d drive.
    How can I solve this problem?

    "Many Thanks",
    Glen Conaway

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What prevents you from accessing the files on your CDROM drive? Works fine for me. Do you get an error? What happens? Do you have a disc in? (Might sound stupid but I gotta ask)

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    San Diego
    Posts
    14
    I think it's a permission problem. I was messing around with it and I got this message:
    "You do not have permission to open this file.
    See the owner of the file or administrator to obtain permission."

    I don't understand because I am logged in as administrator in Windows XP Proffessional.

    A CD is in the drive, if no CD is in the drive I get a message to insert a disk into the drive.

    When I insert a disk no files show up. In the files of type I have
    WAV files (*.wav)

    The Open File Dialog works anywhere on my hard drive but not on my CD ROM

    Comercial programs such as Music Match, Nero, ect. have no problem accessing my CD ROM

    "Many Thanks"

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Post your code. It worked fine for me so it might be something to do with the filter you are using. So is the problem opening the file? Or it not showing wave files?

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    San Diego
    Posts
    14
    It turns out I was assuming that a cd had .wav files. A simple change to the browse button to accept all files solved the problem, but now I have to figure out how to play a .cda file.

    "Thanks"
    Glen Conaway

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you just want the default application on the client computer to play them (assuming there is one) then you can use Process.Start("MyFile.cda")

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    San Diego
    Posts
    14
    I am having problems playing the file from my CD ROM.
    I put the file in a textbox.
    I am trying to get the file to play when I click a button called btnTest.

    Here is my code:

    Imports System.IO
    Public Class Form1
    Inherits System.Windows.Forms.Form

    'api to play wav files
    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszName As String, ByVal dwFlags As Long) As Long
    Const SND_ASYNC = &H1


    ' Declare variable...
    Private strFileName As String = "C:\Temp\Text Docment.txt"


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btuBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btuBrowse.Click
    Dim soundFile As String
    ' Ste the Open dialog porperties...
    With ofdBrowse
    .Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
    .FilterIndex = 1
    .InitialDirectory = "C:\Temp\"
    .Title = "Demo Open File Dialog"
    End With

    ' Show the Open dialog and if the user clicks the OC button,
    ' load the file...
    If ofdBrowse.ShowDialog() = DialogResult.OK Then
    txtSoundFile.Text = ofdBrowse.FileName

    End If
    End Sub

    Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
    Dim soundFile As String = txtSoundFile.Text
    ' simply play the file in the textbox

    'The following line works with wav files on the hard drive
    'sndPlaySound(soundFile, SND_ASYNC)

    'This line doesn't work, I've got something wrong with my code
    Process.Start("soundFile.cda")



    End Sub
    Friend WithEvents btnTest As System.Windows.Forms.Button

    Private Sub txtFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Friend WithEvents txtSoundFile As System.Windows.Forms.TextBox

    Private Sub txtSoundFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSoundFile.TextChanged

    End Sub
    Friend WithEvents ofdBrowse As System.Windows.Forms.OpenFileDialog
    Friend WithEvents btuBrowse As System.Windows.Forms.Button

    Private Sub ofdBrowse_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofdBrowse.FileOk

    End Sub
    End Class


    Thanks for your patience, I am a newbe with alot to learn,
    Glen Conaway

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Process.Start needs the whole path so it should be something like:
    Process.Start("D:\soundFile.cda")

    Now when you say it doesn't work what does that mean? Do you get an error? Nothing happens? If its an error then which one?

    I've never actually tried this with a cda file but in theory it should work as long as there is an application associated with the cda extension.

    EDIT: Actually I just tested it and it worked fine for me using:
    Process.Start("D:\Track01.cda")

    This fired off Winamp (my associated application) and started to play the file.

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    San Diego
    Posts
    14
    Thanks allot for your help.
    I didnt have the drive letter in my textbox.

    I realized this when I ran your line of code and it worked.

    I fixed the problem by changing the RestoreDirectory property on the open file dialog to true.

    Life is good!

    "Many thanks"
    Glen Conaway

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