简体   繁体   English

写入远程服务器上的文件

[英]Writing To A File On A Remote Server

I added a file to \\Windev1\\wwwroot\\dvg 我在\\ Windev1 \\ wwwroot \\ dvg中添加了一个文件

Which is the location on the network of where the source code is that I am using. 这是我正在使用的源代码所在网络的位置。

Now when I try to open the file in code I get an exception that says 现在,当我尝试在代码中打开文件时,我得到了一个异常

Access to the path '\\Windev1\wwwroot\dvg\ProductsToXml.xml' is denied.

The code I am using to access the file is 我用来访问该文件的代码是

Dim writer As New XmlTextWriter("\\Windev1\wwwroot\dvg\ProductsToXml.xml", Nothing)

Is this from an regular desktop application or from an ASP.NET page? 这是来自常规桌面应用程序还是来自ASP.NET页面? If it is from an ASP.NET web app then you will need to run your application as a user that has access to the remote folder or impersonate that user before you try to access the file. 如果它来自ASP.NET Web应用程序,那么您将需要以有权访问远程文件夹的用户身份运行应用程序,或者在尝试访问该文件之前模拟该用户。

If it is a regular desktop application then I would expect that you would get the same error in Windows explorer which just means that you need to give your logged in user permissions on the remote folder. 如果它是常规桌面应用程序,那么我希望您在Windows资源管理器中会遇到相同的错误,这意味着您需要在远程文件夹上提供您的登录用户权限。

Also, if your app is a Windows service you should change the user credentials that the service runs under to a user that has access to the network share. 此外,如果您的应用是Windows服务,则应将服务运行的用户凭据更改为有权访问网络共享的用户。

The problem is described in the error; 问题在错误中描述; the user account that the OS is using to run your application does not have sufficient rights as a non-elevated user to access the file. 操作系统用于运行应用程序的用户帐户没有足够的权限作为非提升用户来访问该文件。

Just a guess, but usually access to web server directories is pretty tightly controlled at the OS level. 只是一个猜测,但通常访问Web服务器目录在操作系统级别受到严格控制。 Make sure that your user account (or NetworkService if this code is a Windows service or web app) has read/modify permissions on this file. 确保您的用户帐户(如果此代码是Windows服务或Web应用程序,则为NetworkService)具有对此文件的读取/修改权限。 Simply having the user be an Administrator won't work; 简单地让用户成为管理员是行不通的; Administrator accounts are run by default with standard user permissions, and are "elevated" to administrative privileges when necessary (which a program will not request by default; it will simply fail). 管理员帐户默认使用标准用户权限运行,并在必要时“提升”为管理权限(默认情况下程序不会请求;它将失败)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将文件写入远程服务器 - Writing file to remote server 通过我的服务器将文件从远程服务器复制到客户端浏览器,而无需将整个文件写入磁盘或内存 - Copy file from remote server to client browser via my server without writing the entire file to disk or memory itextsharp-将文件保存到远程服务器 - itextsharp - saving file to remote server 在远程服务器上运行脚本文件 - Run script file on remote server 写入CloudAppendBlob:远程服务器返回错误:(409)Conflict&ProcessExpectedStatusCodeNoException - Writing to CloudAppendBlob: The remote server returned an error: (409) Conflict & ProcessExpectedStatusCodeNoException 编写连接字符串以访问远程SQL Server数据库 - Writing a connection string to access a remote SQL Server database 比较远程服务器和本地服务器中文件的 FileInfo - To compare FileInfo of file in remote server and local server 将SQL Server表写入文件的快速方法 - Fast way of writing SQL server table into file 将文件写入Web服务器 - ASP.NET - Writing file to web server - ASP.NET 如何同步套接字服务器中的线程以写入文件 - How to synchronize threads in socket server for writing to file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM