Jump to content

OpenFileDialog

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Thomas Morgan

Thomas Morgan

    Newbie

  • Members
  • PipPip
  • 13 posts

Quote

private void btnMusic_Click(object sender, EventArgs e)
{
opnMusic.ShowDialog();
}

This is probably stupid, but since I'm completely new, I don't care.

Problem is that it doesn't open the files when i click open in the dialog.

#2
ArekBulski

ArekBulski

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,376 posts
I assume that opnMusic is a OpenFileDialog control. Well, ShowDialog() only displays the dialog box and returns a value, which says that you clicked OK or cancelled.

If you want to open a file with default program, then you need a Process class from System.Diagnostics namespace.
Process Class (System.Diagnostics)


//I write from memory so errors are possible.

using System.Diagnostics;


Process.Start(opnMusic.FileName);

Edited by ArekBulski, 01 September 2009 - 09:57 PM.


#3
Thomas Morgan

Thomas Morgan

    Newbie

  • Members
  • PipPip
  • 13 posts
Wow... I simply forgot adding that "using System.Diagnostics;".

Thanks for helping out even though it was such a simple matter... :)


If I then wanted to play song directly from my program, then how should I do that? I read something about needing a codec to read the data of the mp3 files, and then save the data in a variable, right? I just don't have any idea how I should start, or even what codec to use.

#4
ArekBulski

ArekBulski

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,376 posts
I wrote two tutorials for you. I hope they will come handy. :)
http://forum.codecal...p3-files-c.html
http://forum.codecal...ed-directx.html

#5
Thomas Morgan

Thomas Morgan

    Newbie

  • Members
  • PipPip
  • 13 posts
Wow, awesome! Thanks!

Edited by Thomas Morgan, 03 September 2009 - 05:00 AM.