Results 1 to 5 of 5
  1. #1
    __]H[elroos's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Rome
    Posts
    301
    Reputation
    44
    Thanks
    842
    My Mood
    Angelic

    Writing Resources To Disk

    Hi mpgh!
    I would like to know how to extract some files in the disk C:\ , previously uploaded in the resources of the program.

    (Sorry for my bad english, i dont know some words then i use google translater and it's not really good...)

    Pls help me!

    Press Rep if you like my programs and my helps


  2. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Code:
    My.Computer.FileSystem.WriteAllBytes("C:\Filename.extension",My.Resources.MyResourceName,False)
    Replace first parameter with the name of the file you want it to be saved into and replace the second parameter with the name of your resource.

  3. #3
    __]H[elroos's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Rome
    Posts
    301
    Reputation
    44
    Thanks
    842
    My Mood
    Angelic
    Thanks, i test it.

    ---------- Post added at 11:58 PM ---------- Previous post was at 11:42 PM ----------

    Thanks, it's working!!
    Problem solved.

    ---------- Post added 07-06-2012 at 12:11 AM ---------- Previous post was 07-05-2012 at 11:58 PM ----------

    Can you add me on skype? I'm RevengeHelroos

    Press Rep if you like my programs and my helps


  4. #4
    Paul's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    6,296
    Reputation
    473
    Thanks
    1,061
    My Mood
    Sleepy
    Quote Originally Posted by Hassan View Post
    Code:
    My.Computer.FileSystem.WriteAllBytes("C:\Filename.extension",My.Resources.MyResourceName,False)
    Replace first parameter with the name of the file you want it to be saved into and replace the second parameter with the name of your resource.
    Shouldn't you check first if the file exists before you eventually replace it?

    Code:
    	If My.Computer.FileSystem.FileExists("C:\Filename.extension") Then
               	MsgBox("File exists")
            Else
                Dim myFile As Object = My.Resources.Filename
            		IO.File.WriteAllBytes("C:\Filename.extension", myFile)
            End If


  5. #5
    __]H[elroos's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Rome
    Posts
    301
    Reputation
    44
    Thanks
    842
    My Mood
    Angelic
    No, because i have to delete all files and then replace these.

    ---------- Post added at 12:56 PM ---------- Previous post was at 12:10 PM ----------

    I need it for a cleaner and for a installer, but thanks for 2nd version of the code!

    Press Rep if you like my programs and my helps


Similar Threads

  1. [Help] Using IO.File.WriteAllBytes to write from resources. [solved]
    By Takari in forum Visual Basic Programming
    Replies: 5
    Last Post: 12-01-2011, 07:05 AM
  2. NEED HELP ON HOW TO FIX WRITE PROTECTED USB DISK
    By killbyme in forum Suggestions, Requests & General Help
    Replies: 3
    Last Post: 09-25-2011, 11:16 PM
  3. [Help] Saving resources to disk?[Solved]
    By master131 in forum Visual Basic Programming
    Replies: 3
    Last Post: 12-16-2010, 02:22 AM
  4. [Vb.net] Write folder with files from resource to..
    By ppl2pass in forum Visual Basic Programming
    Replies: 23
    Last Post: 05-29-2010, 03:08 AM
  5. [SOURCE CODE]Write File To Disk From Resources[VB.NET]
    By ajvpot in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 2
    Last Post: 03-30-2010, 08:54 PM