Click here to Skip to main content
15,902,445 members
Home / Discussions / C#
   

C#

 
AnswerRe: Application Settings File: Folder Location Pin
M-20004-Nov-05 0:40
M-20004-Nov-05 0:40 
GeneralRe: Application Settings File: Folder Location Pin
André Ziegler4-Nov-05 3:32
André Ziegler4-Nov-05 3:32 
QuestionCustom control including several controls Pin
smoitry2-Nov-05 22:23
smoitry2-Nov-05 22:23 
AnswerRe: Custom control including several controls Pin
smoitry2-Nov-05 23:22
smoitry2-Nov-05 23:22 
Questionproblem calling a P/Invoke Pin
jtmtv182-Nov-05 22:19
jtmtv182-Nov-05 22:19 
AnswerRe: problem calling a P/Invoke Pin
Joel Lucsy4-Nov-05 9:38
Joel Lucsy4-Nov-05 9:38 
QuestionCrystal Reports Pin
bootn2-Nov-05 19:34
bootn2-Nov-05 19:34 
QuestionSpecified cast is not valid.??? Pin
Natural Cause2-Nov-05 15:56
Natural Cause2-Nov-05 15:56 
private bool SaveFile(string path, ref byte[] buffer)
{
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

FileStream newFile = new FileStream(path, FileMode.Create);

newFile.Write(buffer, 0, buffer.Length);
if (newFile.CanRead)
{
newFile.Close();
impersonationContext.Undo();
return true;
}
else
{
impersonationContext.Undo();
return false;
}
}

I get an invalid cast on this line:
impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

Any idea why? This is when i try to impersonate while uploading a file. I can;t seem to solve the problem.


-----------------------

In addition, if i remove the impersonation stuff, i get prompted, if i enter the username and password it works fine. So am i using the right code to impersonate?
-- modified at 23:14 Wednesday 2nd November, 2005
AnswerRe: Specified cast is not valid.??? Pin
Judah Gabriel Himango2-Nov-05 16:13
sponsorJudah Gabriel Himango2-Nov-05 16:13 
GeneralRe: Specified cast is not valid.??? Pin
Natural Cause2-Nov-05 16:20
Natural Cause2-Nov-05 16:20 
AnswerRe: Specified cast is not valid.??? Pin
S. Senthil Kumar2-Nov-05 19:02
S. Senthil Kumar2-Nov-05 19:02 
QuestionTab control issues Pin
Christian Graus2-Nov-05 13:32
protectorChristian Graus2-Nov-05 13:32 
AnswerRe: Tab control issues Pin
Judah Gabriel Himango2-Nov-05 16:11
sponsorJudah Gabriel Himango2-Nov-05 16:11 
QuestionRunning Example/Demo Pin
Nkdnt2-Nov-05 13:26
Nkdnt2-Nov-05 13:26 
AnswerRe: Running Example/Demo Pin
Christian Graus2-Nov-05 13:31
protectorChristian Graus2-Nov-05 13:31 
QuestionRe: Running Example/Demo Pin
Nkdnt2-Nov-05 14:21
Nkdnt2-Nov-05 14:21 
AnswerRe: Running Example/Demo Pin
Christian Graus2-Nov-05 14:23
protectorChristian Graus2-Nov-05 14:23 
GeneralRe: Running Example/Demo Pin
Nkdnt2-Nov-05 14:30
Nkdnt2-Nov-05 14:30 
GeneralRe: Running Example/Demo Pin
Christian Graus2-Nov-05 14:35
protectorChristian Graus2-Nov-05 14:35 
QuestionHow do i go about debugging code that runs fine on my PC but not on others? Pin
Red_Wizard_Shot_The_Food2-Nov-05 12:15
Red_Wizard_Shot_The_Food2-Nov-05 12:15 
AnswerRe: How do i go about debugging code that runs fine on my PC but not on others? Pin
Christian Graus2-Nov-05 13:30
protectorChristian Graus2-Nov-05 13:30 
AnswerRe: How do i go about debugging code that runs fine on my PC but not on others? Pin
S. Senthil Kumar2-Nov-05 19:04
S. Senthil Kumar2-Nov-05 19:04 
AnswerRe: How do i go about debugging code that runs fine on my PC but not on others? Pin
André Ziegler3-Nov-05 2:01
André Ziegler3-Nov-05 2:01 
GeneralRe: How do i go about debugging code that runs fine on my PC but not on others? Pin
Red_Wizard_Shot_The_Food3-Nov-05 2:48
Red_Wizard_Shot_The_Food3-Nov-05 2:48 
GeneralRe: How do i go about debugging code that runs fine on my PC but not on others? Pin
André Ziegler3-Nov-05 13:24
André Ziegler3-Nov-05 13:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.