将文件保存到另一台服务器

时间:2022-04-24 07:27:42

What kind of path would I use to save a file (.pdf) on another server/network drive? Say I have rights to a network drive 'optamail1' and a folder there called datasheets. I can access this folder from "Run" using \\optamail1\datasheets\, however, this kind of path will not work in my application. Has anyone tried doing this before?

我将使用什么样的路径将文件(.pdf)保存在另一台服务器/网络驱动器上?假设我拥有网络驱动器'optamail1'和一个名为datasheets的文件夹的权限。我可以使用\\ optamail1 \ datasheets \从“运行”访问此文件夹,但是,这种路径在我的应用程序中不起作用。有人试过这样做吗?

Thanks, Nick

2 个解决方案

#1


5  

You need to grant access to the network share to the user that the ASP.Net application is running as.

您需要向运行ASP.Net应用程序的用户授予对网络共享的访问权限。

#2


0  

To save "report.pdf" at "\optamail1\datasheets\", you would just use the path "\optamail1\datasheets\report.pdf" as normal. You should enclose the save operation inside a try/catch and check for exceptions in case: the path doesn't exist, net is down/computer not accesible, or you don't have permission to write on that path.

要将“report.pdf”保存在“\ optamail1 \ datasheets \”,您只需正常使用路径“\ optamail1 \ datasheets \ report.pdf”。您应该将保存操作包含在try / catch中,并在以下情况下检查异常:路径不存在,net已关闭/计算机无法访问,或者您无权在该路径上写入。

#1


5  

You need to grant access to the network share to the user that the ASP.Net application is running as.

您需要向运行ASP.Net应用程序的用户授予对网络共享的访问权限。

#2


0  

To save "report.pdf" at "\optamail1\datasheets\", you would just use the path "\optamail1\datasheets\report.pdf" as normal. You should enclose the save operation inside a try/catch and check for exceptions in case: the path doesn't exist, net is down/computer not accesible, or you don't have permission to write on that path.

要将“report.pdf”保存在“\ optamail1 \ datasheets \”,您只需正常使用路径“\ optamail1 \ datasheets \ report.pdf”。您应该将保存操作包含在try / catch中,并在以下情况下检查异常:路径不存在,net已关闭/计算机无法访问,或者您无权在该路径上写入。