无法从 SharePoint Server 2007 (MOSS) 执行 System.IO.File.Move 到网络驱动器
我正在使用 VS2008 C# 和 MOSS (SharePoint Server 2007)。
我创建了一个 asp.net Web 表单,该表单显示在 SharePoint 网站内的 WebPart 上。提交表单时,会生成一个小的 .csv 文件。理想情况下,我希望在网络驱动器(在另一台服务器上)上创建此文件,但由于某种原因我无法执行此操作。我可以愉快地在我正在处理的 SharePoint 服务器本身的硬盘驱动器上创建该文件,但它永远不会出现在我选择的任何网络驱动器上。
然后我想我应该首先在我的 c: 驱动器上创建该文件(因为它可以工作),然后使用 asp.net 将文件“移动”到网络目录。我用过:
System.IO.File.Move(sourceFile, destinationFile);
这在“移动”阶段也失败了。 - 文件创建得很好!在我正在使用的 MOSS 服务器上,有一个 C: 驱动器和一个 D: 驱动器(已分区)。文件创建在两个驱动器上都可以正常工作,但即使我避免使用如下驱动器映射,也不能在任何网络驱动器上工作:(
例如 "G:\\Group Files\\" 或 "\ \\\Global\\Group Files\\" )
显然,我认为安全是一个问题,因此我确保 MOSS 服务器和网络服务器都允许彼此使用 Active Directory 进行“完全访问”。我什至授予我自己作为用户、管理组、ASPNET 帐户、NETWORK SERVICE 帐户(以及其他帐户)等的修改访问权限。还是没有喜悦。我可以 PING 想要在其上创建 .csv 文件的网络服务器,因此它“看到”了它。
我所做的解决方法是在 SharePoint 服务器的 c: 驱动器上创建文件,然后运行一个批处理文件(按计划),将文件纯粹复制到目标 G: 驱动器 - 这很不错,但我很沮丧我无法使用代码立即在目标服务器上创建文件。
我有预感它与 SharePoint 有关,但如果有人能阐明这个问题,我将非常感激!
预先感谢,阿什;-)
I am using VS2008 C# and MOSS (SharePoint Server 2007).
I have created an asp.net web form which appears on a WebPart within a SharePoint site. When submitting the form, a small .csv file is generated. Ideally I want to have this file created on a network drive (on another server), but for some reason I cannot do this. I can create the file happily on the hard drive of my SharePoint server itself that I am working on, but it just never appears on any network drive that I choose.
I then thought I'd create the file on my c: drive first (as it works), then use asp.net to 'Move' the file to the network directory. I used:
System.IO.File.Move(sourceFile, destinationFile);
This failed also at the 'moving' stage. - the file gets created fine! On the MOSS server I am working on, there is a C: drive and a D: drive (partitioned). The file creation works fine on both drives, but just not any network drive even if I avoid using drive mappings as below:
(e.g. "G:\\Group Files\\" or "\\\\Global\\Group Files\\" )
Obviously, I thought security was an issue, so I ensured the MOSS server and the network server both allowed each other with 'Full Access' using Active Directory. I even granted access to myself as a user, admin groups, the ASPNET account, NETWORK SERVICE account (amongst others), etc with MODIFY access. Still no joy. I can PING the network server that I want to create the .csv file on, so it is 'seeing' it.
The work-around that I have done is create the file on the SharePoint server's c: drive, then run a batch file (on schedule) that purely copies the file to the destination G: drive - this works a treat, but I am frustrated that I cannot create the file on the destination server straight away, using code.
I've got a hunch it is SharePoint related, but if anyone can shed light on this matter I'd be extremely grateful!!
Thanks in advance, Ash ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,我今天遇到了这个问题,在寻找答案时发现了这个帖子。我的问题是我的临时目录没有正确的权限!当然,我可以毫无问题地上传文件,但除非使用 LAN 帐户,否则我无法移动它。我确保网络服务和我的共享点应用程序池具有访问权限,并确保上传文件的用户也具有权限。然后就成功了。
Ah, I had this problem today and found this thread whilst looking for an answer. My problem was that my temp directory didn't have the right permissions! Sure, I could get the file uploaded without issue, but I couldn't move it unless I were using a LAN account. I made sure NETWORK SERVICE and my sharepoint application pool had access, and made sure the user who was uploading the file had permission too. Then it worked.