Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Creating Large, Blank Bitmaps Pin
Pete O'Hanlon6-May-15 5:00
mvePete O'Hanlon6-May-15 5:00 
GeneralRe: Creating Large, Blank Bitmaps Pin
JBHowl6-May-15 5:03
JBHowl6-May-15 5:03 
GeneralRe: Creating Large, Blank Bitmaps Pin
Pete O'Hanlon6-May-15 8:50
mvePete O'Hanlon6-May-15 8:50 
AnswerRe: Creating Large, Blank Bitmaps Pin
OriginalGriff6-May-15 6:14
mveOriginalGriff6-May-15 6:14 
GeneralRe: Creating Large, Blank Bitmaps Pin
JBHowl6-May-15 7:16
JBHowl6-May-15 7:16 
QuestionHow can I use webcam in WebBrowser Control? Pin
Member 116126625-May-15 17:45
Member 116126625-May-15 17:45 
AnswerRe: How can I use webcam in WebBrowser Control? Pin
Dr Gadgit6-May-15 2:14
Dr Gadgit6-May-15 2:14 
QuestionC# Get Audio File From Resources Pin
Kevin Marois5-May-15 9:03
professionalKevin Marois5-May-15 9:03 
I need to copy an audio file from resources to the HD:
private void EnsureDefaultFileExists()
{
    var outputFile = Path.Combine(FileSystemLocations.GetTempFilesDirectory(), "fc6sound.wav");

    if (!File.Exists(outputFile))
    {
        var targetAssembly = Assembly.GetExecutingAssembly();
        var resourceName = "fc6sound.wav";

        using (Stream stream = targetAssembly.GetManifestResourceStream(targetAssembly.GetName().Name + "." + resourceName))
        {
            if (stream == null)
            {
                throw new Exception("Cannot find embedded resource '" + resourceName + "'");
            }

            byte[] buffer = new byte[stream.Length];

            stream.Read(buffer, 0, buffer.Length);

            using (BinaryWriter sw = new BinaryWriter(File.Open(outputFile, FileMode.Create)))
            {
                sw.Write(buffer);

            }
        }
    }
}

This isn't working. The exception is thrown. I've tried it with and without the ".wav". Anyone see what's wrong?

Thanks
If it's not broken, fix it until it is

AnswerRe: C# Get Audio File From Resources Pin
Sascha Lefèvre5-May-15 10:28
professionalSascha Lefèvre5-May-15 10:28 
GeneralRe: C# Get Audio File From Resources Pin
Kevin Marois5-May-15 10:50
professionalKevin Marois5-May-15 10:50 
GeneralRe: C# Get Audio File From Resources Pin
Sascha Lefèvre5-May-15 11:02
professionalSascha Lefèvre5-May-15 11:02 
GeneralRe: C# Get Audio File From Resources Pin
Kevin Marois5-May-15 11:05
professionalKevin Marois5-May-15 11:05 
GeneralRe: C# Get Audio File From Resources Pin
Kevin Marois5-May-15 11:17
professionalKevin Marois5-May-15 11:17 
GeneralRe: C# Get Audio File From Resources Pin
Sascha Lefèvre5-May-15 11:32
professionalSascha Lefèvre5-May-15 11:32 
GeneralRe: C# Get Audio File From Resources Pin
Kevin Marois5-May-15 11:33
professionalKevin Marois5-May-15 11:33 
GeneralRe: C# Get Audio File From Resources Pin
Sascha Lefèvre5-May-15 11:35
professionalSascha Lefèvre5-May-15 11:35 
GeneralRe: C# Get Audio File From Resources Pin
Mycroft Holmes5-May-15 14:15
professionalMycroft Holmes5-May-15 14:15 
GeneralRe: C# Get Audio File From Resources Pin
Sascha Lefèvre6-May-15 1:46
professionalSascha Lefèvre6-May-15 1:46 
Questiontell me about patterns Pin
Member 116654285-May-15 0:26
Member 116654285-May-15 0:26 
AnswerRe: tell me about patterns Pin
Richard MacCutchan5-May-15 0:29
mveRichard MacCutchan5-May-15 0:29 
AnswerRe: tell me about patterns Pin
OriginalGriff5-May-15 0:34
mveOriginalGriff5-May-15 0:34 
GeneralRe: tell me about patterns Pin
CHill606-May-15 0:53
mveCHill606-May-15 0:53 
AnswerRe: tell me about patterns Pin
Sascha Lefèvre5-May-15 0:54
professionalSascha Lefèvre5-May-15 0:54 
AnswerRe: tell me about patterns Pin
Dave Kreskowiak5-May-15 2:30
mveDave Kreskowiak5-May-15 2:30 
AnswerRe: tell me about patterns Pin
Pete O'Hanlon6-May-15 1:50
mvePete O'Hanlon6-May-15 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.