wpf file embeded resource is readonly,Copy always will copy the file and its folder to the bin folder

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); 
        }

相关文章

自1998年我国取消了福利分房的政策后,房地产市场迅速开展蓬...
文章目录获取数据查看数据结构获取数据下载数据可以直接通过...
网上商城系统MySql数据库设计
26个来源的气象数据获取代码
在进入21世纪以来,中国电信业告别了20世纪最后阶段的高速发...