We have a SQL Server, App Server and 2 front ends that we are running SharePoint on. There is a shared network drive that a sharepoint timer job needs to read in xml files from. I can access the shared network drive from each server and it looks like permissions are set up correctly.
The timer job uses the following code to try and read in the XML files from the shared drive:
foreach (string file in Directory.GetFiles(@"\\SPAPPPROD1\WellnessHRA", "*.xml").Where(item => item.EndsWith(".xml")))
{
// Load the XML file, loop through and populate the HRA list:
XDocument doc = XDocument.Load(file);
IEnumerable<XElement> hraItems = doc.Root.Elements();
foreach (var item in hraItems)
{
HRA hra = new HRA();
hra.HRAFileName = file.Replace(@"\\SPAPPPROD1\WellnessHRA", "");
hra.MemberID = item.Element("ValidationData").Value;
hra.FirstName = item.Element("FirstName").Value;
hra.LastName = item.Element("LastName").Value;
hra.Email = item.Element("EmailAddress").Value;
hra.DateCompleted = DateTime.ParseExact(item.Element("ResultDate").Value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
hra.IsManualEntry = false;
hraList.Add(hra);
}
// Move the XML file to the Archive folder (Using try/catch because I'm not sure they gave proper file security. Will remove the try/catch once verified sharepoint can move files:
try
{
var newFile = file.Replace(@"\\SPAPPPROD1\WellnessHRA", @"\\SPAPPPROD1\WellnessHRA\Archive");
File.Move(file, newFile);
}
catch { }
}The code above cannot find the shared network drive. Does anyone have any advice/how to trouble-shoot this issue? It shouldn't matter what server the timer job runs on since they all can access the shared drive correct?