[SOURCE CODE]Write File To Disk From Resources[VB.NET]

Posts 1–3 of 3 · Page 1 of 1
[SOURCE CODE]Write File To Disk From Resources[VB.NET]
Just add your file to the resources of the project and declare the resource in your variables.

Code:
        '''''''''''''''''''''''''''''''''''
        '''''''Declare variables     ''''''
        '''''''''''''''''''''''''''''''''''
        Dim newFilePath As String
        Dim resource As Array
        '''''''''''''''''''''''''''''''''''
        '''''''Put data in variables'''''''
        '''''''''''''''''''''''''''''''''''
        newFilePath = "C:/test/test.ext" 'your file path (string)
        resource = My.Resources.something ' resouce=YOUR RESOURCE  my.resources.something
        '''''''''''''''''''''''''''''''''''
        '''''''Write file           '''''''
        '''''''''''''''''''''''''''''''''''
        Using sCreateFile As New IO.FileStream(newFilePath, IO.FileMode.Create)
            sCreateFile.Write(resource, 0, resource.Length)
        End Using
        '''''''''''''''''''''''''''''''''''
        '''''''DONE!                '''''''
        '''''''''''''''''''''''''''''''''''
you can make it write to the temp directory with this code

Code:
        Dim temppath
        temppath = If(Environ$("tmp") <> "", Environ$("tmp"), Environ$("temp"))
newFilePath = temppath + "/file.ext"
Hope this helps someone
Just remember to give credits.
To whom? I made this, just not the temp directory finder thingy... I cant edit my post
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us