Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi copy file to system32

code:
C#
private void button1_Click(object sender, EventArgs e)
        {
            string path64=null, path32 = null;
            if (Environment.Is64BitOperatingSystem)
            {
                path64 = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "SysWOW64\\");
                path32 = Environment.GetFolderPath(Environment.SpecialFolder.System)+"\\";
                MessageBox.Show(path64);
            }
            else
            {
                path32 = Environment.GetFolderPath(Environment.SpecialFolder.System);
                MessageBox.Show(path32);
            }

            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (path64 != null)
                {
                    System.IO.File.Copy(ofd.FileName, @path64 + ofd.SafeFileName);
                }
                System.IO.File.Copy(ofd.FileName, @path32 + ofd.SafeFileName);

            }
        }


error:
Access to the path is denied.


please help me.

What I have tried:

hi
copy file to system32

please help me.
Posted
Updated 3-Feb-18 22:52pm
Comments
Mehdi Gholam 4-Feb-18 2:54am    
Try running as an administrator.

1 solution

It's quite simple. ..users are prevented from copying files to system folders.

You can get around it by running your program in Administrator mode, but you shouldn't.

Think about what System32 is (clue is in the name) and why user access might be read only
 
Share this answer
 
Comments
Maciej Los 4-Feb-18 5:27am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900