3 Replies Latest reply on Jan 11, 2013 1:54 PM by Luc St-Pierre

    CopyDocument() in C++

    Zsolt Zsupán
      Hi!

      Sorry my stupid question, but why not working this function?

      The source in SW API help (and I modified, why it buggy...) I compiled MS VC++ 6.0

      int CopyDoc(ISldWorks* swApp)
      {
      long Err = -1;
      BSTR src, dst, chld_src[6], chld_dst[6];

      src = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\DLC000_001.SLDASM");
      dst = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\DLC000_002.SLDASM");
      chld_src[0] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\Dc00_DLC000_1_001.SLDASM");
      chld_src[1] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\Dc0001_Dc00_DLC000_1_001.SLDPRT");
      chld_src[2] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\Dc0002_Dc00_DLC000_1_001.SLDPRT");
      chld_src[3] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\Dc0003_Dc00_DLC000_1_001.SLDPRT");
      chld_src[4] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\Dc0003_Dc00_DLC000_2_001.SLDPRT");
      chld_src[5] = SysAllocString(L"C:\\Work\\Test\\DLC000_001\\modul_DLC000_001.SLDPRT");
      chld_dst[0] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\Dc00_DLC000_1_002.SLDASM");
      chld_dst[1] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\Dc0001_Dc00_DLC000_1_002.SLDPRT");
      chld_dst[2] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\Dc0002_Dc00_DLC000_1_002.SLDPRT");
      chld_dst[3] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\Dc0003_Dc00_DLC000_1_002.SLDPRT");
      chld_dst[4] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\Dc0003_Dc00_DLC000_2_002.SLDPRT");
      chld_dst[5] = SysAllocString(L"C:\\Work\\Test\\DLC000_002\\modul_DLC000_002.SLDPRT");

      swApp->ICopyDocument(src, dst, 6, chld_src, chld_dst,
      swMoveCopyOptionsOverwriteExistingDocs + swMoveCopyOptionsCreateNewFolder,
      &Err);

      return 0;
      }

      I get a error code: 2 ("Failed to create destination directories or copy operation failed possibly because you do not have proper permissions")
      Why??? :-(
      Have you idea anybody?

      Thanks!
      ZsZs.