1
I need to find a file path .wav in C#
. I can find and execute the .wav
with the complete path "c: caminhox...", however, I need the application to find the file in any directory that he is.
I tried to do it this way:
var file = new FileInfo(Path.Combine(Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location), @"Alarm.wav"));
SoundPlayer soundPlayer = new SoundPlayer(file.ToString());
soundPlayer.Play();
but he can’t find the Alarm wav., ask:
- What is missing?
- There’s another way to do it?
Automatically find? how so
– novic
Without having the complete path, I was with the project on my flash drive ("F: PATH ON THE THUMB DRIVE"), then I switched to a directory on my machine and it does not find the file because it is no longer in the same path... The file is in the project folder, but it does not find
– dev-john
If you have to inform a valid path to run, guess the application cannot, if you can put this file next to the executable and take the path of the executable and pass the name of the wav!? maybe this will solve your problem right away.
– novic
is a Windows Forms application?
– novic
That’s what I’m trying to do... Yeah, it’s WF
– dev-john
If you have already placed the file with the executable?
– novic
Yes, it’s in the case Resources
– dev-john
Let’s go continue this discussion in chat.
– novic