0

How to just load whatever data is the resource, and then decide what type the data is and just load it on the element control?

public static dynamic ReadResource(System.String Parameter1)
{
    return new System.Uri(@"pack://application:,,,/RESOURCES/" + Parameter1, System.UriKind.RelativeOrAbsolute);
}

var testing = ReadResource("resource1");

if (testing.GetType() == typeof(System.String)
    MyLabel.Content = testing;

Thanks;

H3sDW11e
  • 188
  • 1
  • 3
  • 11
  • Does this answer your question? [Reading From a Text File in C#](https://stackoverflow.com/questions/7980456/reading-from-a-text-file-in-c-sharp) – Ibrennan208 Jul 01 '22 at 02:56
  • https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-from-a-text-file – Ibrennan208 Jul 01 '22 at 02:56

1 Answers1

0

SOLUTION

WPF Application Resource, Content, and Data Files
had researched a solution and reconstructed the code sample;

public static dynamic ReadResource(System.String Parameter1){
var _myPackURI_ = new System.Uri("/RESOURCES/"+Parameter1, System.UriKind.RelativeOrAbsolute); //[?] Pack URI;
var _myStream_  = System.Windows.Application.GetResourceStream( _myPackURI_ );                 //[?] Resource Stream;
var _myReader_  = new System.IO.StreamReader( _myStream_.Stream );                             //[?] Stream Reader;
return _myReader_.ReadToEnd(); //[?] Stream Reader Operation;
}


/* ... */
var testing = ReadResource("resource1");
if (testing.GetType() == typeof(System.String))
System.Console.WriteLine( testing );
H3sDW11e
  • 188
  • 1
  • 3
  • 11