如何在c#中的同一网络中的另一台机器上保存文件?

我必须将上传的文档保存到另一台本地计算机上。 但我不清楚如何在我的代码中使用模拟。

我使用了以下代码。

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

您可以使用UNC路径指向您具有写权限的公共共享。

(例如\\ computerName \ PublicShareFolder)

您可以通过ACL检查是否拥有权限(为该路径创建DirectoryInfo对象并获取ACL以检查您是否具有写权限)然后您可以写入该路径。