1

When I am trying to create a new directory in my WPF application i am getting the following error.

" 'The invocation of the constructor on type 'NetworkApplication.Login' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'."

this is my line of code

DirectoryInfo di = Directory.CreateDirectory(@"C:\\Windows\\Newfolder1");
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
swati
  • 21
  • 2
  • 4
  • Run the application in VS debugger, set a breakpoint at that line, step over it and check the exception. – Clemens Oct 22 '12 at 10:33
  • You can't create directories in the c:\windows directory. Not unless you elevate rights for your program. Don't do it. – Hans Passant Oct 22 '12 at 13:11
  • possible duplicate of [How to force my .NET App to run as administrator on Windows 7](http://stackoverflow.com/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7) – Hans Passant Oct 22 '12 at 13:11

1 Answers1

3

Besides the security issues, you're trying to escape a string that has the @ in front of it. Either remove the @ or un-escape the slashes.