-1
FileStream fs=new FileStream("c:/samplehubdata.xml",
                             FileMode.OpenOrCreate,
                             FileAccess.ReadWrite,
                             FileShare.ReadWrite);
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

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
  • 5,087
  • 3
  • 22
  • 40
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
  • 477
  • 3
  • 13