FileStream fs=new FileStream("c:/samplehubdata.xml",
FileMode.OpenOrCreate,
FileAccess.ReadWrite,
FileShare.ReadWrite);
Asked
Active
Viewed 697 times
-1

Linda Lawton - DaImTo
- 106,405
- 32
- 180
- 449

Aditya Nair
- 19
- 2
-
So add permission to the process that your program is running under. How is this even a question? – NightOwl888 Oct 27 '17 at 07:30
2 Answers
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
- Go to your project and click add
- Select Visual C# Items
- Select "Application Manifest File"
- Call this app.manifest (I guess it is by default)

Florian Zaskoku
- 477
- 3
- 13
-
I'm writing a C# code so I'm not sure if I will have an app.manifest file. – Aditya Nair Oct 27 '17 at 07:31
-
I know. Every project has a app.manifest file. Give me a second I will edit my post – Florian Zaskoku Oct 27 '17 at 07:31
-
Glad I was able to help you :) Feel free to leave a green tick ;D – Florian Zaskoku Oct 27 '17 at 07:40