question

JunYoungLee-5266 avatar image
0 Votes"
JunYoungLee-5266 asked vb2ae answered

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

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-wpfdotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

vb2ae avatar image
0 Votes"
vb2ae answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.