how to save file in another machine in the same ne

2019-05-23 18:09发布

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);
....................................................................................
....................................................................................
}

2条回答
三岁会撩人
3楼-- · 2019-05-23 19:16

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.

查看更多
登录 后发表回答