I am using C#/.Net2.0
I am connecting to a remote shared folder from my C# code using WNetAddConnection2A without mapping to the local drive.
A code snippet is:
Expand|Select|Wrap|Line Numbers
- NetResource netRes = new NetResource();
- netRes.scope = RESOURCE_GLOBALNET;
- netRes.type = RESOURCETYPE_DISK;
- netRes.displayType = RESOURCEDISPLAYTYPE_SHARE;
- netRes.usage = RESOURCEUSAGE_CONNECTABLE;
- netRes.remoteSharedName = shareName;
- netRes.localMappedDriveName = localMappedDrive;
- int retcode = WNetAddConnection2A(ref netRes, pwd, usr, 0);
- String[] fileColl = Directory.GetFiles(shareName);
- // foreach file in fileColl
- DateTime dt = File.GetLastWriteTime(absFileName);//Here the exception is thrown.
Type : System.IO.IOException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089The above block of code is in base class, and its been used by two different childs which are called from two different threads. A pseudo class is given below.
Message : An unexpected network error occurred.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void WinIOError(Int32, System.String)
Stack Trace : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.GetLastWriteTimeUtc(String path)
at System.IO.File.GetLastWriteTime(String path)
Expand|Select|Wrap|Line Numbers
- class base
- {
- // above code snippet
- }
- class d1: base
- {
- }
- class d2: base
- {
- }
Thanks
Ram