resource file in VB.NET
How can I use a .exe file in my resources folder? I want to copy the file in the resource folder to another folder.
tried this
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (Directory.Exists("Files")) Then
Else
End If
Directory.CreateDirectory("Files")
Dim FileToCopy As String
Dim NewCopy As String
FileToCopy = My.Resources.THEFILEIWANT <- only this part doesn't work
NewCopy = "Files\THEFILEIWANT.exe"
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
End If
End Sub
This is needed so when ther file doesn't exists the file gets created/copied.
Does anyone knows how I can call the file from the reso开发者_StackOverflowurce folder?
Tried this ` Dim writePermission As FileIOPermission writePermission = New FileIOPermission(FileIOPermissionAccess.Write)
If (SecurityManager.IsGranted(writePermission)) Then
My.Computer.FileSystem.WriteAllBytes("Files", My.Resources.unscrambler, False)
End If`
But I'm getting a invalid permission error.
I am still a beginner but I could suggest using a packer, such as the one included with CodePlex's Confuser. It packs multiple assemblies into one (as do all packers), and obviously, Confuser offers obfuscation, and is Free.
*One warning!* Packers have been known to raise alerts in Anti-virus software, so check your app with different AV software.
Hope this info is useful. :)
精彩评论