问题
I have to save the uploaded document into another local machine. But I was not clear how to use impersonation in my code.
I have used the following code.
protected void btnSave_Click(object sender, EventArgs e)
{
int result = 0,result1=0;
string attachmentpath = "C:\\Documents and Settings\\pr84528\\My Documents\\PRABU\\Tech\\Dot Net\\DocumentManager\\Attachments\\";
....................................................................................
....................................................................................
if(fuDocument.HasFile)
fuDocument.SaveAs(attachmentpath + fuDocument.FileName);
....................................................................................
....................................................................................
}
回答1:
I think here is your solution. http://bytes.com/topic/net/answers/853352-create-text-file-network-path-using-c
回答2:
You can use a UNC path to a public share where you have write rights.
(ex. \\computerName\PublicShareFolder)
You can check if you have rights via ACL (create a DirectoryInfo object for that path and get ACL for it to check if you have write rights) and then you can write to that path.
来源:https://stackoverflow.com/questions/13911647/how-to-save-file-in-another-machine-in-the-same-network-in-c