title: File.Copy error: The requested operation could not be completed due to a file system limitation
body: <p>After getting more than 4000000 jpeg files in structure we've problem with adding new.
  File.Copy throw an exception: The requested operation could not be completed due to a file system limitation.</p>
  
  <p>Any solution?</p>
  
  <p><strong>Info</strong></p>
  
  <ul>
  <li><strong>System:</strong> Windows Server 2008 SP1 x64</li>
  <li><strong>Installed path:</strong> <a href="http://support.microsoft.com/kb/967351/en-us?fr=1" rel="noreferrer">http://support.microsoft.com/kb/967351/en-us?fr=1</a></li>
  <li><strong>Defragmentation:</strong> done</li>
  </ul>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    public bool AddFile(Uri uri, string path, bool withDelete = false)
      {
          var sourceFilePath = path;
          var destinationFilePath = Path.GetFullPath(uri.LocalPath);
  
          try
          {
              if (!File.Exists(sourceFilePath))
              {
                  sourceFilePath = Directory.EnumerateFiles(sourceFilePath).FirstOrDefault();
                  destinationFilePath = Path.Combine(destinationFilePath, Path.GetFileName(sourceFilePath));
              }
  
              if (!Directory.Exists(Path.GetDirectoryName(destinationFilePath)))
                  Directory.CreateDirectory(Path.GetDirectoryName(destinationFilePath));
  
              if (withDelete &amp;&amp; File.Exists(destinationFilePath))
                  File.Delete(destinationFilePath);
  
              File.Copy(sourceFilePath, destinationFilePath);
  
              return true;
          }
          catch (Exception exc)
          {
              ServiceCore.GetLogger().Error(exc);
              throw exc;
          }
      }
  </code></pre>
  
  <p><strong>Stacktrace</strong></p>
  
  <pre><code>    2013-03-28 14:10:48.3784[Info]: 47356388:Unive.NetService.SimpleServices.DocumentManagementSerivce..ctor: Entry
      2013-03-28 14:10:48.4740[Info]: Static:Unive.NetService.SimpleServices.DocumentManagementSerivce..ctor: Success
      2013-03-28 14:10:48.4899[Info]: 47356388:Unive.NetService.SimpleServices.DocumentManagementSerivce.UploadFile: Entry
      2013-03-28 14:11:26.3277[Error]: Exception
      Message:The requested operation could not be completed due to a file system limitation
  
      Source:mscorlib
      Stack Trace:   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
         at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
         at Unive.NetService.Business.SimpleFileClient.AddFile(Uri uri, String path, Boolean withDelete) in D:\Tag Prografix\Unive.NetService\Business\SimpleFileClient.cs:line 33
      TargetSite:Void WinIOError(Int32, System.String)
      2013-03-28 14:11:26.5029[Error]:                         47356388:Unive.NetService.SimpleServices.DocumentManagementSerivce.UploadFileException
      Message:The requested operation could not be completed due to a file system limitation
  
      Source:mscorlib
      Stack Trace:   at Unive.NetService.Business.SimpleFileClient.AddFile(Uri uri, String path, Boolean withDelete) in D:\Tag Prografix\Unive.NetService\Business\SimpleFileClient.cs:line 42
         at Unive.NetService.Business.FileService.UploadFile(Int64 fileId, String fileName, String path, Boolean isDiagram) in D:\Tag Prografix\Unive.NetService\Business\FileService.cs:line 80
         at Unive.NetService.SimpleServices.DocumentManagementSerivce.UploadFile(Int64 fileId, String fileName, String path) in D:\Tag Prografix\Unive.NetService\SimpleServices\DocumentManagementSerivce.asmx.cs:line 100
      TargetSite:Void WinIOError(Int32, System.String)
  </code></pre>