To reduce your confusion, Im repeating my tasks.
You are correct. I don't want to pop-up the connect dlg. I need to connect to
\\SomeComp\SomeShare through C# Program & copy the required files to my local machine. Both computers are in WORKGROUP. To prepare the required file list, I have to access the last modified time of the
\\SomeComp\SomeShare\file.txt, and if it passes my filter, do copy it to my local pc. To summarize this,
- 1) Connect to the remote share through WNetAddConnection2A
-
by using share, un, pwd.
-
//Fetches the file names.
-
2) Use String[] fileColl = Directory.GetFiles();
-
3)
-
foreach(String fn in fileColl)
-
{
-
DateTime dtModTime = File.GetLastWriteTime(fn);
-
if(dtLastCollTime < dtModTime)
-
{
-
// Do something
-
}
-
}
One doubt is that, how much time Windows XP will maintain one network sesssion which we open through the API call. Is there any limit on this? Of course, my code will not take much time...hardly around 12sec.Also, my code uses 3connections to 3diffrent sub folders of the
SomeShare and these are the maximum connections used by my code at one point of time.
Also, recently I noticed that, even if we use single session also, the same fancy error is recurring. In single connection case, it some times fails.
But, in multi connection cases, one of the 3connections is failing always.