玻儿,雪之梦下载,sihu
wpf file embeded resource will compile the file into the assembly and it will be readonly and can not be writable.
using system.io; using system.reflection; void readembededresourcedemo() { var assembly = assembly.getexecutingassembly(); var names = assembly.getmanifestresourcenames(); var resourcename = "wpfapplication7.resource.jsondata.json"; using (stream stream = assembly.getmanifestresourcestream(resourcename)) using (streamreader reader = new streamreader(stream)) { string result = reader.readtoend(); messagebox.show(result); } }
while you set the file as copy always it will copy the file and its folder to *.exe location.
void writeresourcealwayscopy() { string dir = directory.getcurrentdirectory(); var allfiles=directory.getfiles(dir, "*", searchoption.alldirectories); var jsonfile = @".\resource\jsondata.json"; string jsoncontent=file.readalltext(jsonfile); file.appendalltext(jsonfile, jsoncontent, encoding.utf8); }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
asp.net搭建博客,使用BlogEngine.NET+MySql搭建博客
网友评论