[DllImport(“NetApi32.dll”… throws exception for first few times

shoab.shah

New member
Joined
Feb 27, 2013
Messages
2
Programming Experience
3-5
Hi All,

am using [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] to access, save files to a network location. The problem is File creation / save work fails for first few attempts and laters starts working fine. After a time interval say 5-6 hours again it fails first few time.
Thanks in advance
 

shoab.shah

New member
Joined
Feb 27, 2013
Messages
2
Programming Experience
3-5
Hi All,

am using [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] to access, save files to a network location. The problem is File creation / save work fails for first few attempts and laters starts working fine. After a time interval say 5-6 hours again it fails first few time.
Thanks in advance


Here is a part of code

[XCODE]
string FAXFilePrefix = Helper.Helper.GetConfigValue("FAXFilePrefix"); string domainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; string location = GetLocalStoragePath() + FAXFilePrefix + requestViewModel.encounter.ServiceEncounterID + "_" + uniqueId.ToString() + ".docx"; // Backup (archive/todaysdate folder) MvcApplication.TraceSource.TraceEvent(TraceEventType.Information, 100, "Before Accessing UNC path "); using (Carena.PCHA.CoreServices.UncPath.UNCAccessWithCredentials unc = new Carena.PCHA.CoreServices.UncPath.UNCAccessWithCredentials()) { if (unc.NetUseWithCredentials(Path, userName, domainName, Password)) { MvcApplication.TraceSource.TraceEvent(TraceEventType.Information, 100, "Before docx.SaveAs "); MvcApplication.TraceSource.TraceEvent(TraceEventType.Information, 100, "Location - "+location); try { docx.SaveAs(location); } catch (Exception ex) { loggerl.LogException(ex); } MvcApplication.TraceSource.TraceEvent(TraceEventType.Information, 100, "After docx.SaveAs "); }[/XCODE]

It throws exception at docx.SaveAs(location); line
 
Top Bottom