[Help] Saving resources to disk?[Solved]

Posts 1–4 of 4 · Page 1 of 1
[Help] Saving resources to disk?[Solved]
I have a resource file that I would like to save to my HDD during run-time however, I'm getting a 0 byte file. This is what Kevin gave me (and was too lazy to help me after that) /

[php] Private Sub FileFromResource(ByVal resource, ByVal outputDir)
Dim bArray() As Byte = resource
Dim fStream As New IO.FileStream(outputDir, IO.FileMode.OpenOrCreate)
Using bWrite As New IO.BinaryWriter(fStream)
Dim i As Integer = 0
Do Until i = bArray.Length
bWrite.Write(i)
i += 1
Loop
End Using
End Sub[/php]

I'm trying to use it on an mp3 file I imported but no progress..
[php]FileFromResource(My.Resources.BGMusic, "BGMusic.mp3")[/php]
It's because you didn't specify the output directory, just the name of the output file. You need to provide a full path like
Code:
C:\Users\Jason\Documents\myMp3.mp3
But the method is a bit of overkill

Try this:

[php]
IO.File.WriteAllBytes("pathhere", My.Resources.ResourceName)
[/php]
Quote Originally Posted by Jason View Post
It's because you didn't specify the output directory, just the name of the output file. You need to provide a full path like
Code:
C:\Users\Jason\Documents\myMp3.mp3
But the method is a bit of overkill

Try this:

[php]
IO.File.WriteAllBytes("pathhere", My.Resources.ResourceName)
[/php]
Thanks! Worked like a charm!
Awesome, glad it worked
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us