Results 1 to 15 of 15

Thread: [HELP]Save From Resource File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Angry [HELP]Save From Resource File

    Hey ive been look for a code like this for so long
    here is a fake code i want u to translate to vb2008
    Code:
    File.save("C:/Pathway/") from my.resource.MYFILE.exe
    please help me out i wanta save a exe file

    [SOLVED] {THANKS JMCHILHINNEY!!!!!!! (<----<3 this guy) + Watson123 + minitech
    (Add to references)
    Dim b() As Byte = My.Resource.myfile 'Name of file in resources
    IO.File.WriteAllBytes("location of your file",b)
    Last edited by LoGiCAnti; Apr 22nd, 2010 at 09:41 PM. Reason: solved

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP]Save From Resource File

    My.Resources will return a Byte array. IO.File.WriteAllBytes has a Byte array parameter.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    Quote Originally Posted by jmcilhinney View Post
    My.Resources will return a Byte array. IO.File.WriteAllBytes has a Byte array parameter.
    well how would i do that?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    bump please

  5. #5
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Re: [HELP]Save From Resource File

    Code:
    Dim ipw As New IO.MemoryStream(my.resource.MYFILE.exe)
            Dim qyi As IO.FileStream = IO.File.OpenWrite("C:/Pathway/yourfile.exe")
            ipw.WriteTo(qyi)
            qyi.Close()

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Angry Re: [HELP]Save From Resource File

    Quote Originally Posted by watson123 View Post
    Code:
    Dim ipw As New IO.MemoryStream(my.resource.MYFILE.exe)
            Dim qyi As IO.FileStream = IO.File.OpenWrite("C:/Pathway/yourfile.exe")
            ipw.WriteTo(qyi)
            qyi.Close()
    when i put that it in it cant see the exe file

  7. #7
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [HELP]Save From Resource File

    Code:
    Dim b() As Byte = My.Resource.myfile 'Name of file in resources
    IO.File.WriteAllBytes("location of your file",b)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    Quote Originally Posted by minitech View Post
    Code:
    Dim b() As Byte = My.Resource.myfile 'Name of file in resources
    IO.File.WriteAllBytes("location of your file",b)

    http://s295.photobucket.com/albums/m...ent=help-1.png
    still didnt work i dont know if ur gettn what im try say so look at that pic please ill so <3 u if u get this 2 work
    n yes i tried everything!
    Last edited by LoGiCAnti; Apr 22nd, 2010 at 05:58 PM. Reason: rong img source

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    bump

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP]Save From Resource File

    Oh, we get it alright. Have a look at the Resources page of the project properties. What is listed there? Is that where you added the file as a resource?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [HELP]Save From Resource File

    Well, first of all, you don't put the ".exe" there.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    Quote Originally Posted by minitech View Post
    Well, first of all, you don't put the ".exe" there.
    tried it

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP]Save From Resource File

    Quote Originally Posted by LoGiCAnti View Post
    tried it
    I'm yet to see answers to my questions.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    106

    Re: [HELP]Save From Resource File

    Quote Originally Posted by jmcilhinney View Post
    Oh, we get it alright. Have a look at the Resources page of the project properties. What is listed there? Is that where you added the file as a resource?
    HEY IT SEE IT NOW <3 so much!!! i guess i couldnt add it to the sidebar thing

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP]Save From Resource File

    Quote Originally Posted by LoGiCAnti View Post
    i guess i couldnt add it to the sidebar thing
    If you mean the Solution Explorer then you certainly can add the file there but you then can't access it via My.Resources. My.Resources relates specifically to resources added to the Resources page of the project properties. If you add the file to the Solution Explorer and then set the Build Action to Embedded Resource, a resource is added but you must write some extra code to use a ResourceManager to retrieve the data yourself rather than My.Resources doing it for you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width