在Windows 7和我的C#程序中复制问题

Gol*_*old 1 c# windows-7

我在我的C#程序中这样做:

File.copy(Application.StartupPath + "\Test.txt",@"c:\Test.txt");
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

Access to  the path 'c\Test.txt' is denied
Run Code Online (Sandbox Code Playgroud)

它只发生在Windows 7中,在Windows XP中它运行良好.

Tho*_*mas 10

访问被拒绝.这意味着您无权访问.不,确实如此.

默认情况下,Windows 7中的用户帐户是有限的(非管理员),因此您的程序不能只写在系统上的任何位置(这是一个Good Thing(TM)).尝试放入Test.txt另一个目录,例如临时目录(询问系统的位置).