Is there any way in WPF to deploy and then modify the embedded file?

JunYoungLee 161 Reputation points
2022-05-28T13:08:59.39+00:00

I made an app in C# WPF and deployed it via FTP.
In my app, a csv file is included as an embedded source, and the information in this csv file is read and displayed in a list view.
I want other users to be able to add information from this csv file.
But I haven't found any way yet.
And I want to know how to refer to the latest modified csv file from the deployed app when I edit the app later.
Otherwise, if I update it, it will be displayed in the list view as an unmodified csv file.

I would appreciate it if you could tell me how to edit the csv file after deployment.
The code below is part of the code I use to read and use embedded files.

DataTable dt_local_path = new DataTable();
            dt_local_path = GetCSVData("Load_Spectrum2.Resources.Setting_Local_Path.csv");

private DataTable GetCSVData(string str_path)
        {
            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(str_path);
            StreamReader file = new StreamReader(stream);

            DataTable table = new DataTable();
            var flag_dtcolumn = 0;

            while (!file.EndOfStream)
            {
                string line = file.ReadLine();
                string[] data = line.Split(',');

                if (flag_dtcolumn == 0)
                {
                    foreach (string s in data)
                    {
                        table.Columns.Add(s);
                    }
                }
                else
                {
                    table.Rows.Add(data.ToArray());
                }

                flag_dtcolumn++;

            }

            return table;
        }
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,676 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
766 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,846 Reputation points
    2022-05-29T00:36:07.447+00:00

    You can't modify an embedded file with your app. You would need to save the file to the computer the first time your app is run and read and save to/from the file on the computer

    0 comments No comments