开发者

Adding .csv file as resource file and accessing it in the code

开发者 https://www.devze.com 2022-12-22 12:55 出处:网络
I hav开发者_开发问答e a .csv file which i will read using oledb method in my code now i want this .csv file as my resourcefile so i have added that file in the resources.

I hav开发者_开发问答e a .csv file which i will read using oledb method in my code now i want this .csv file as my resource file so i have added that file in the resources. But struct with accessing the resource file from the code, can anyone please help me on this

Thanks


Assuming that your CSV file is embedded as a resource you could access it like this:

using (var stream = Assembly
    .GetExecutingAssembly()
    .GetManifestResourceStream("YourNamespace.test.csv"))
using (var reader = new StreamReader(stream))
{
    string csv = reader.ReadToEnd();
    // do something with the CSV
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号