I'm currently using .NET Framework 4.7.2 on Visual Studio 2019 to make a Win Form that converts audio formats. The problem is that I'm getting an Access Denied Error saying that I cant save my converted WAV file cannot be stored in a directory.
This is the part that gives me the error:
string rpath = AppDomain.CurrentDomain.BaseDirectory + "\\Converted";
private void button3_Click(object sender, EventArgs e)
{
if (!Directory.Exists(rpath))
{
Directory.CreateDirectory(rpath);
}
else if (comboBox2.SelectedItem.ToString() == "WAV")
{
using (Mp3FileReader reader = new Mp3FileReader(textBox1.Text))
{
WaveFileWriter.CreateWaveFile(rpath, reader);
}
}
}
And this is the exact error:
System.UnauthorizedAccessException: 'Access to the path 'C:\Users\joswin\Documents\Converter\Converter\Converter\bin\Debug\Converted' is denied.'
My current guess is that NAudio's WaveFileWriter is causing the issue, but I don't know another way to convert audio files at the moment.
I've already tried running this in Administrator and yet it didn't work, it still gave me the same error.