Hack Forums
[C#] How to read an external resource in C# [Added in resource hacker] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] How to read an external resource in C# [Added in resource hacker] (/showthread.php?tid=5116090)



How to read an external resource in C# [Added in resource hacker] - FileBoss - Dec 31, 2015

Hi, I was wondering if it's possible to read a resource, post build of original exe, say in the exe you try to find a text file you added in resource hacker and read it as a string. Thanks


* - GuRuHaX - Dec 31, 2015

PHP Code

<?php 
// Example #1
        // Read the file as one string.
     
  
string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");

 
// Example #2
        // Read each line of the file into a string array. Each element
        // of the array is one line of the file.
       
 
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt"); 
Is that what your asking for?

Kind regards 🤝


* - BahNahNah - Jan 2, 2016

(Dec 31, 2015 11:29 AM)GuRuHaX Wrote:  -code-
Is that what your asking for?

Kind regards 🤝

Thats not reading a resource at all.
OP, You are probaby looking for native resource, have a look at his: https://gist.github.com/BahNahNah/e30f7e45b7a2f3c91160
Usage:
Code
string myString = NativeResource.ReadResourceString("nameofresource");