0

I'm trying to create a program that uses SpeechSynthisizer to save some speech to C:\speech.wav, but I get an error that I don't have permission to do so. I would like to know how I am able request admin privileges for my program, so that I will be able to do so.

Update: Thanks all of you guys for your help, but I can only choose one of you, sorry.

Notice to Moderators: This thread can be closed.

chabad360
  • 640
  • 1
  • 8
  • 16
  • can you please share your code, what have you done so far ? – warrior May 18 '15 at 20:54
  • 3
    And moving your file to a less protected location? The root of C disk is not the correct place to store data files. Try to use your ProgramData folder or your document folder but try to avoid the root of a system drive – Steve May 18 '15 at 20:57
  • Actually to be more specific I need to make a tutorial for a lib I made, the purpose being, that if someone gets asked if my lib wants access, they might get suspicions, but if the program they are using asks they will say yes. also, The MSDN tutorial for this is a bit complicated, so I'm having trouble understanding it... – chabad360 May 18 '15 at 20:59
  • Possible duplicate of http://stackoverflow.com/questions/23686502/write-file-in-c-drive-permission-issue – Mazen Elkashef May 18 '15 at 21:10
  • I'm only writing to `C:\\` for tests – chabad360 May 18 '15 at 21:47
  • @IKashef It didnt really help... – chabad360 May 18 '15 at 21:51

3 Answers3

1

Here is a related question with some alternatives. I like Steve B's idea of creating a new folder in C:\

C#, Creating .txt file

Community
  • 1
  • 1
DenverJT
  • 125
  • 7
1

Write the file under the CommonApplicationData folder known as ProgramData under the recent Windows OS installations.

string programDataDir = 
       Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
string subDir = "MyApp";
string logFilePath = Path.Combine(programDataDir, subDir);

Then save your WAV file under this directory. For Windows Vista/7/8, this will be "C:\ProgramData\MyApp\" and there should be no security permissions issue for writing under this directory.

Derek W
  • 9,708
  • 5
  • 58
  • 67
0

You need to create an application manifest for your executable or dll and assign administrator access through there. This will prompt an administrator prompt, as windows sees fit, during runtime. See this thread: How do I force my .NET application to run as administrator?

Community
  • 1
  • 1
Shahzad Qureshi
  • 1,776
  • 14
  • 15