-1
FileStream fs=new FileStream("c:/samplehubdata.xml",
                             FileMode.OpenOrCreate,
                             FileAccess.ReadWrite,
                             FileShare.ReadWrite);
DaImTo
  • 88,623
  • 26
  • 153
  • 389

2 Answers2

1

You usually cannot create a file on Windows in C:\ without admin priviliges.

Try creating it in your user folder instead.

gonutz
  • 4,246
  • 3
  • 16
  • 36
1

Write this to get admin access to write on C

<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

to your app.manifest You can create this file if you are not able to see the app.manifest. If you want to know more about the app.manifest you can look here

//edited because he wanted to know how

  1. Go to your project and click add
  2. Select Visual C# Items
  3. Select "Application Manifest File"
  4. Call this app.manifest (I guess it is by default)
Florian Zaskoku
  • 457
  • 3
  • 13