Cannot execute System.IO.File.Move to a network drive from SharePoint Server 2007 (MOSS)
I am using VS2008 C# and MOSS (ShareP开发者_StackOverflowoint 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 ;-)
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.
精彩评论