I am trying to copy a file using this –
private void button1_Click(object sender, EventArgs e)
{
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (File.Exists(@"C:\Users\%UserProfile%\AppData\Roaming\.minecraft\bin\minecraft.jar"))
try
{
File.Copy(@"C:\Users\%UserProfile%\AppData\Roaming\.minecraft\bin\minecraft.jar", @"C:\Users\%UserProfile%\Documents\MinecraftBackup\minecraft.jar", true);
}
and it won’t work unless I change %UserProfile% to my actual username, how do i fix this?
Instead of:
try
In fact, any time you see “
C:\Users\%UserProfile%\AppData\Roaming\“, you should use “Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)“.