0

I am having problems on overwriting a file's content from another file in my application's Resources. I tried using File.WriteAllBytes(path, Properties.Resources.MyResource), but it didn't work. I know the file is there, it will never be nonexistent. What I need to do is simply copy the resource to the specified path. My function that is supposed to work:

public void Swap(bool v) {
        byte[] file = Properties.Resources.Resource;
        if (v) {
            file = Properties.Resources.Resource;
        } else {
            file = Properties.Resources.Backup;
        }
        stateBox.IsChecked = v;
        string path = Process.GetProcessesByName("Process")[0].Modules[0].FileName.Replace("Process.exe", "") + "File.txt";
        MessageBox.Show(path);
        File.Create(path);
        File.WriteAllBytes(path, file);
    }

0 Answers0