how to save file in another machine in the same network in c#?

喜夏-厌秋 提交于 2019-12-22 10:48:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!