<p>I am looking for a robust way to copy files over a Windows network share that is tolerant of intermittent connectivity. The application is often used on wireless, mobile workstations in large hospitals, and I'm assuming connectivity can be lost either momentarily or for several minutes at a time. The files involved are typically about 200KB - 500KB in size. The application is written in VB6 (ugh), but we frequently end up using Windows DLL calls.</p>

<p>Thanks!</p>

[{'answer_id': 18178, 'author': 'TheSmurf', 'author_id': 1975282, 'author_profile': 'https://Stackoverflow.com/users/1975282', 'pm_score': 3, 'selected': False, 'text': '<p>Try using BITS (Background Intelligent Transfer Service). It\'s the infrastructure that Windows Update uses, is accessible via the Win32 API, and is built specifically to address this.</p>\n\n<p>It\'s usually used for application updates, but should work well in any file moving situation.</p>\n\n<p><a href="http://www.codeproject.com/KB/IP/bitsman.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/IP/bitsman.aspx</a></p>\n'}, {'answer_id': 18179, 'author': 'Erik van Brakel', 'author_id': 909, 'author_profile': 'https://Stackoverflow.com/users/909', 'pm_score': 0, 'selected': False, 'text': '<p>How about simply sending a hash after or before you send the file, and comparing that with the file you received? That should at least make sure you have a correct file.</p>\n\n<p>If you want to go all out you could do the same process, but for small parts of the file. Then when you have all pieces, join them on the receiving end.</p>\n'}, {'answer_id': 18927, 'author': 'Joel Spolsky', 'author_id': 4, 'author_profile': 'https://Stackoverflow.com/users/4', 'pm_score': 4, 'selected': False, 'text': '<p>I\'ve used <a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Robocopy</a> for this with excellent results. By default, it will retry every 30 seconds until the file gets across.</p>\n'}, {'answer_id': 19606, 'author': 'Mark Brackett', 'author_id': 2199, 'author_profile': 'https://Stackoverflow.com/users/2199', 'pm_score': 4, 'selected': True, 'text': '<p>I\'m unclear as to what your actual problem is, so I\'ll throw out a few thoughts.</p>\n\n<ul>\n<li>Do you want restartable copies (with such small file sizes, that doesn\'t seem like it\'d be that big of a deal)? If so, look at <a href="http://msdn.microsoft.com/en-us/library/aa363852.aspx" rel="nofollow noreferrer">CopyFileEx with COPYFILERESTARTABLE</a></li>\n<li>Do you want verifiable copies? Sounds like you already have that by verifying hashes.</li>\n<li>Do you want better performance? It\'s going to be tough, as it sounds like you can\'t run anything on the server. Otherwise, <a href="http://msdn.microsoft.com/en-us/library/ms740565%28VS.85%29.aspx" rel="nofollow noreferrer">TransmitFile</a> may help.</li>\n<li>Do you just want a fire and forget operation? I suppose shelling out to robocopy, or <a href="http://www.codesector.com/teracopy.php" rel="nofollow noreferrer">TeraCopy</a> or something would work - but it seems a bit hacky to me.</li>\n<li>Do you want to know when the network comes back? <a href="http://msdn.microsoft.com/en-us/library/aa377522%28VS.85%29.aspx" rel="nofollow noreferrer">IsNetworkAlive</a> has your answer.</li>\n</ul>\n\n<p>Based on what I know so far, I think the following pseudo-code would be my approach:</p>\n\n<pre><code>sourceFile = Compress("*.*");\ndestFile = "X:\\files.zip";\n\nint copyFlags = COPYFILEFAILIFEXISTS | COPYFILERESTARTABLE;\nwhile (CopyFileEx(sourceFile, destFile, null, null, false, copyFlags) == 0) {\n   do {\n     // optionally, increment a failed counter to break out at some point\n     Sleep(1000);\n   while (!IsNetworkAlive(NETWORKALIVELAN));\n}\n</code></pre>\n\n<p>Compressing the files first saves you the tracking of which files you\'ve successfully copied, and which you need to restart. It should also make the copy go faster (smaller total file size, and larger single file size), at the expense of some CPU power on both sides. A simple batch file can decompress it on the server side.</p>\n'}, {'answer_id': 21220, 'author': 'Shawn', 'author_id': 26, 'author_profile': 'https://Stackoverflow.com/users/26', 'pm_score': -1, 'selected': False, 'text': "<p>SMS if it's available works.</p>\n"}, {'answer_id': 39559, 'author': 'Robbo', 'author_id': 2418, 'author_profile': 'https://Stackoverflow.com/users/2418', 'pm_score': 2, 'selected': False, 'text': '<p>I agree with Robocopy as a solution...thats why the utility is called <em>"Robust File Copy"</em></p>\n\n<blockquote>\n  <p>I\'ve used Robocopy for this with excellent results. By default, it will retry every 30 seconds until the file gets across.</p>\n</blockquote>\n\n<p>And by default, a million retries. That should be plenty for your intermittent connection. </p>\n\n<p>It also does restartable transfers and you can even throttle transfers with a gap between packets assuing you don\'t want to use all the bandwidth as other programs are using the same connection (/IPG switch)?.</p>\n'}, {'answer_id': 80197, 'author': 'pro', 'author_id': 352728, 'author_profile': 'https://Stackoverflow.com/users/352728', 'pm_score': 0, 'selected': False, 'text': '<p>You could use Microsoft SyncToy (free).</p>\n\n<p><a href="http://www.microsoft.com/Downloads/details.aspx?familyid=C26EFA36-98E0-4EE9-A7C5-98D0592D8C52&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/Downloads/details.aspx?familyid=C26EFA36-98E0-4EE9-A7C5-98D0592D8C52&amp;displaylang=en</a></p>\n'}, {'answer_id': 87955, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Hm, seems rsync does it, and does not need server/daemon/install I thought it does - just $ rsync src dst.</p>\n'}]
['https://Stackoverflow.com/questions/18172', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2144/']