How to load my test data in C#?

后端 未结 1 520
不思量自难忘°
不思量自难忘° 2021-02-11 06:29

I am struggling to find an easy way to load my test data in C#.

In Java, I load a resource using the following code:

...

public static InputStream loadR         


        
1条回答
  •  心在旅途
    2021-02-11 06:50

    Yes - use Assembly.GetManifestResourceStream, e.g.

    typeof(TestClass).Assembly
                     .GetManifestResourceStream("test.namespace.Filename.txt")
    

    Just make sure the files are tagged as "Embedded Resource" in the properties, so they get built into the assembly correctly.

    0 讨论(0)
提交回复
热议问题