Creating thousands of virtual documents using SOLIDWORK PDM API

Came across this when I was working on a project where I needed to test setting variables for thousands files. The method AddFiles is what the API recommends for creating files in batch mode which is blazingly fast compared to AddFile.

The API remarks section needs an update.

The missing note about AddFiles in the API help is that you have to create the virtual documents on disk as opposed to AddFile where you can pass an empty string for the source file.

Here’s an example:


using EPDM.Interop.epdm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CreateVirtualDocuments
{
    class Program
    {
        static void Main(string[] args)
        {
            #region files 

            var files =
@"
[""000"",
""0000"",
""0001"",
""0002"",
""0003"",
""0004"",
""0005"",
""0006"",
""0007"",
""2382"",
""2383"",
""2384"",
""2385"",
""2386"",
""2387"",
""2388"",
""2389"",
""239"",
""2390"",
""2391"",
""2392"",
""2393"",
""2394"",
""2395"",
""2396"",
""2397"",
""2398"",
""2399"",
""240"",
""2400"",
""2401"",
""2402"",
""2403"",
""2404"",
""2405"",
""2406"",
""2407"",
""2408"",
""2409"",
""241"",
""2410"",
""2411"",
""2412"",
""2413"",
""2414"",
""2415"",
""2416"",
""2417"",
""2418"",
""2419"",
""242"",
""2420"",
""2421"",
""2422"",
""2423"",
""2424"",
""2425"",
""2426"",
""2427"",
""2428"",
""2429"",
""243"",
""2430"",
""2431"",
""2432"",
""2433"",
""2434"",
""2435"",
""2436"",
""2437"",
""2438"",
""2439"",
""244"",
""2440"",
""2441"",
""2442"",
""2443"",
""2444"",
""2445"",
""2446"",
""2447"",
""2448"",
""2449"",
""245"",
""2450"",
""2451"",
""2452"",
""2453"",
""2454"",
""2455"",
""2456"",
""2457"",
""2458"",
""2459"",
""246"",
""2460"",
""2461"",
""2462"",
""2463"",
""2464"",
""2465"",
""2466"",
""2467"",
""2468"",
""2469"",
""247"",
""2470"",
""2471"",
""2472"",
""2473"",
""2474"",
""2475"",
""2476"",
""2477"",
""2478"",
""2479"",
""248"",
""2480"",
""2481"",
""2482"",
""2483"",
""2484"",
""2485"",
""2486"",
""2487"",
""2488"",
""2489"",
""249"",
""2490"",
""2491"",
""2492"",
""2493"",
""2494"",
""2495"",
""2496"",
""2497"",
""2498"",
""2499"",
""250"",
""2500"",
""2501"",
""2502"",
""2503"",
""2504"",
""2505"",
""2506"",
""2507"",
""2508"",
""2509"",
""251"",
""2510"",
""2511"",
""2512"",
""2513"",
""2514"",
""2515"",
""2516"",
""2517"",
""2518"",
""2519"",
""252"",
""2520"",
""2521"",
""2522"",
""2523"",
""2524"",
""2525"",
""2526"",
""2527"",
""2528"",
""2529"",
""253"",
""2530"",
""2531"",
""2532"",
""2533"",
""2534"",
""2535"",
""2536"",
""2537"",
""2538"",
""2539"",
""254"",
""2540"",
""2541"",
""2542"",
""2543"",
""2544"",
""2545"",
""2546"",
""2547"",
""2548"",
""2549"",
""255"",
""2550"",
""2551"",
""2552"",
""2553"",
""2554"",
""2555"",
""2556"",
""2557"",
""2558"",
""2559"",
""256"",
""2560"",
""2561"",
""2562"",
""2563"",
""2564"",
""2565"",
""2566"",
""2567"",
""2568"",
""2569"",
""257"",
""2570"",
""2571"",
""2572"",
""2573"",
""2574"",
""2575"",
""2576"",
""2577"",
""2578"",
""2579"",
""258"",
""2580"",
""2581"",
""2582"",
""2583"",
""2584"",
""2585"",
""2586"",
""2587"",
""2588"",
""2589"",
""259"",
""2590"",
""2591"",
""2592"",
""2593"",
""2594"",
""2595"",
""2596"",
""2597"",
""2598"",
""2599"",
""260"",
""2600"",
""2601"",
""2602"",
""2603"",
""2604"",
""2605"",
""2606"",
""2607"",
""2608"",
""2609"",
""261"",
""2610"",
""2611"",
""2612"",
""2613"",
""2614"",
""2615"",
""2616"",
""2617"",
""2618"",
""2619"",
""262"",
""2620"",
""2621"",
""2622"",
""2623"",
""2624"",
""2625"",
""2626"",
""2627"",
""2628"",
""2629"",
""263"",
""2630"",
""2631"",
""2632"",
""2633"",
""2634"",
""2635"",
""2636"",
""2637"",
""2638"",
""2639"",
""264"",
""2640"",
""2641"",
""2642"",
""2643"",
""2644"",
""2645"",
""2646"",
""2647"",
""2648"",
""2649"",
""265"",
""2650"",
""2651"",
""2652"",
""2653"",
""2654"",
""2655"",
""2656"",
""2657"",
""2658"",
""2659"",
""266"",
""2660"",
""2661"",
""2662"",
""2663"",
""2664"",
""2665"",
""2666"",
""2667"",
""2668"",
""2669"",
""267"",
""2670"",
""2671"",
""2672"",
""2673"",
""2674"",
""2675"",
""2676"",
""2677"",
""2678"",
""2679"",
""268"",
""2680"",
""2681"",
""2682"",
""2683"",
""2684"",
""2685"",
""2686"",
""2687"",
""2688"",
""2689"",
""269"",
""2690"",
""2691"",
""2692"",
""2693"",
""2694"",
""2695"",
""2696"",
""2697"",
""2698"",
""2699"",
""270"",
""2700"",
""2701"",
""2702"",
""2703"",
""2704"",
""2705"",
""2706"",
""2707"",
""2708"",
""2709"",
""271"",
""2710"",
""2711"",
""2712"",
""2713"",
""2714"",
""2715"",
""2716"",
""2717"",
""2718"",
""2719"",
""272"",
""2720"",
""2721"",
""2722"",
""2723"",
""2724"",
""2725"",
""2726"",
""2727"",
""2728"",
""2729"",
""273"",
""2730"",
""2731"",
""2732"",
""2733"",
""2734"",
""2735"",
""2736"",
""2737"",
""2738"",
""2739"",
""274"",
""2740"",
""2741"",
""2742"",
""2743"",
""2744"",
""2745"",
""2746"",
""2747"",
""2748"",
""2749"",
""275"",
""2750"",
""2751"",
""2752"",
""2753"",
""2754"",
""2755"",
""2756"",
""2757"",
""2758"",
""2759"",
""276"",
""2760"",
""2761"",
""2762"",
""2763"",
""2764"",
""2765"",
""2766"",
""2767"",
""2768"",
""2769"",
""277"",
""2770"",
""2771"",
""2772"",
""2773"",
""2774"",
""2775"",
""2776"",
""2777"",
""2778"",
""2779"",
""278"",
""2780"",
""2781"",
""2782"",
""2783"",
""2784"",
""2785"",
""2786"",
""2787"",
""2788"",
""2789"",
""279"",
""2790"",
""2791"",
""2792"",
""2793"",
""2794"",
""2795"",
""2796"",
""2797"",
""2798"",
""2799"",
""280"",
""2800"",
""2801"",
""2802"",
""2803"",
""2804"",
""2805"",
""2806"",
""2807"",
""2808"",
""2809"",
""281"",
""2810"",
""2811"",
""2812"",
""2813"",
""2814"",
""2815"",
""2816"",
""2817"",
""2818"",
""2819"",
""282"",
""2820"",
""2821"",
""2822"",
""2823"",
""2824"",
""2825"",
""2826"",
""2827"",
""2828"",
""2829"",
""283"",
""2830"",
""2831"",
""2832"",
""2833"",
""2834"",
""2835"",
""2836"",
""2837"",
""2838"",
""2839"",
""284"",
""2840"",
""2841"",
""2842"",
""2843"",
""2844"",
""2845"",
""2846"",
""2847"",
""2848"",
""2849"",
""285"",
""2850"",
""2851"",
""2852"",
""2853"",
""2854"",
""2855"",
""2856"",
""2857"",
""2858"",
""2859"",
""286"",
""2860"",
""2861"",
""2862"",
""2863"",
""2864"",
""2865"",
""2866"",
""2867"",
""2868"",
""2869"",
""287"",
""2870"",
""2871"",
""2872"",
""2873"",
""2874"",
""2875"",
""2876"",
""2877"",
""2878"",
""2879"",
""288"",
""2880"",
""2881"",
""2882"",
""2883"",
""2884"",
""2885"",
""2886"",
""2887"",
""2888"",
""2889"",
""289"",
""2890"",
""2891"",
""2892"",
""2893"",
""2894"",
""2895"",
""2896"",
""2897"",
""2898"",
""2899"",
""290"",
""2900"",
""2901"",
""2902"",
""2903"",
""2904"",
""2905"",
""2906"",
""2907"",
""2908"",
""2909"",
""291"",
""2910"",
""2911"",
""2912"",
""2913"",
""2914"",
""2915"",
""2916"",
""2917"",
""2918"",
""2919"",
""292"",
""2920"",
""2921"",
""2922"",
""2923"",
""2924"",
""2925"",
""2926"",
""2927"",
""2928"",
""2929"",
""293"",
""2930"",
""2931"",
""2932"",
""2933"",
""2934"",
""2935"",
""2936"",
""2937"",
""2938"",
""2939"",
""294"",
""2940"",
""2941"",
""2942"",
""2943"",
""2944"",
""2945"",
""2946"",
""2947"",
""2948"",
""2949"",
""295"",
""2950"",
""2951"",
""2952"",
""2953"",
""2954"",
""2955"",
""2956"",
""2957"",
""2958"",
""2959"",
""296"",
""2960"",
""2961"",
""2962"",
""2963"",
""2964"",
""2965"",
""2966"",
""2967"",
""2968"",
""2969"",
""297"",
""2970"",
""2971"",
""2972"",
""2973"",
""2974"",
""2975"",
""2976"",
""2977"",
""2978"",
""2979"",
""298"",
""2980"",
""2981"",
""2982"",
""2983"",
""2984"",
""2985"",
""2986"",
""2987"",
""2988"",
""2989"",
""299"",
""2990"",
""2991"",
""2992"",
""2993"",
""2994"",
""2995"",
""2996"",
""2997"",
""2998"",
""2999"",
""300"",
""3000"",
""3001"",
""3002"",
""3003"",
""3004"",
""3005"",
""3006"",
""3007"",
""3008"",
""3009"",
""301"",
""3010"",
""3011"",
""3012"",
""3013"",
""3014"",
""3015"",
""3016"",
""3017"",
""3018"",
""3019"",
""302"",
""3020"",
""3021"",
""3022"",
""3023"",
""3024"",
""3025"",
""3026"",
""3027"",
""3028"",
""3029"",
""303"",
""3030"",
""3031"",
""3032"",
""3033"",
""3034"",
""3035"",
""3036"",
""3037"",
""3038"",
""3039"",
""304"",
""3040"",
""3041"",
""3042"",
""3043"",
""3044"",
""3045"",
""3046"",
""3047"",
""3048"",
""3049"",
""305"",
""3050"",
""3051"",
""3052"",
""3053"",
""3054"",
""3055"",
""3056"",
""3057"",
""3058"",
""3059"",
""306"",
""3060"",
""3061"",
""3062"",
""3063"",
""3064"",
""3065"",
""3066"",
""3067"",
""3068"",
""3069"",
""307"",
""3070"",
""3071"",
""3072"",
""3073"",
""3074"",
""3075"",
""3076"",
""3077"",
""3078"",
""3079"",
""308"",
""3080"",
""3081"",
""3082"",
""3083"",
""3084"",
""3085"",
""3086"",
""3087"",
""3088"",
""3089"",
""309"",
""3090"",
""3091"",
""3092"",
""3093"",
""3094"",
""3095"",
""3096"",
""3097"",
""3098"",
""3099"",
""310"",
""3100"",
""3101"",
""3102"",
""3103"",
""3104"",
""3105"",
""3106"",
""3107"",
""3108"",
""3109"",
""311"",
""3110"",
""3111"",
""3112"",
""3113"",
""3114"",
""3115"",
""3116"",
""3117"",
""3118"",
""3119"",
""312"",
""3120"",
""3121"",
""3122"",
""3123"",
""3124"",
""3125"",
""3126"",
""3127"",
""3128"",
""3129"",
""313"",
""3130"",
""3131"",
""3132"",
""3133"",
""3134"",
""3135"",
""3136"",
""3137"",
""3138"",
""3139"",
""314"",
""3140"",
""3141"",
""3142"",
""3143"",
""3144"",
""3145"",
""3146"",
""3147"",
""3148"",
""3149"",
""315"",
""3150"",
""3151"",
""3152"",
""3153"",
""3154"",
""3155"",
""3156"",
""3157"",
""3158"",
""3159"",
""316"",
""3160"",
""3161"",
""3162"",
""3163"",
""3164"",
""3165"",
""3166"",
""3167"",
""3168"",
""3169"",
""317"",
""3170"",
""3171"",
""3172"",
""3173"",
""3174"",
""3175"",
""3176"",
""3177"",
""3178"",
""3179"",
""318"",
""3180"",
""3181"",
""3182"",
""3183"",
""3184"",
""3185"",
""3186"",
""3187"",
""3188"",
""3189"",
""319"",
""3190"",
""3191"",
""3192"",
""3193"",
""3194"",
""3195"",
""3196"",
""3197"",
""3198"",
""3199"",
""320"",
""3200"",
""3201"",
""3202"",
""3203"",
""3204"",
""3205"",
""3206"",
""3207"",
""3208"",
""3209"",
""321"",
""3210"",
""3211"",
""3212"",
""3213"",
""3214"",
""3215"",
""3216"",
""3217"",
""3218"",
""3219"",
""322"",
""3220"",
""3221"",
""3222"",
""3223"",
""3224"",
""3225"",
""3226"",
""3227"",
""3228"",
""3229"",
""323"",
""3230"",
""3231"",
""3232"",
""3233"",
""3234"",
""3235"",
""3236"",
""3237"",
""3238"",
""3239"",
""324"",
""3240"",
""3241"",
""3242"",
""3243"",
""3244"",
""3245"",
""3246"",
""3247"",
""3248"",
""3249"",
""325"",
""3250"",
""3251"",
""3252"",
""3253"",
""3254"",
""3255"",
""3256"",
""3257"",
""3258"",
""3259"",
""326"",
""3260"",
""3261"",
""3262"",
""3263"",
""3264"",
""3265"",
""3266"",
""3267"",
""3268"",
""3269"",
""327"",
""3270"",
""3271"",
""3272"",
""3273"",
""3274"",
""3275"",
""3276"",
""3277"",
""3278"",
""3279"",
""328"",
""3280"",
""3281"",
""3282"",
""3283"",
""3284"",
""3285"",
""3286"",
""3287"",
""3288"",
""3289"",
""329"",
""3290"",
""3291"",
""3292"",
""3293"",
""3294"",
""3295"",
""3296"",
""3297"",
""3298"",
""3299"",
""330"",
""3300"",
""3301"",
""3302"",
""3303"",
""3304"",
""3305"",
""3306"",
""3307"",
""3308"",
""3309"",
""331"",
""3310"",
""3311"",
""3312"",
""3313"",
""3314"",
""3315"",
""3316"",
""3317"",
""3318"",
""3319"",
""332"",
""3320"",
""3321"",
""3322"",
""3323"",
""3324"",
""3325"",
""3326"",
""3327"",
""3328"",
""3329"",
""333"",
""3330"",
""3331"",
""3332"",
""3333"",
""3334"",
""3335"",
""3336"",
""3337"",
""3338"",
""3339"",
""334"",
""3340"",
""3341"",
""3342"",
""3343"",
""3344"",
""3345"",
""3346"",
""3347"",
""3348"",
""3349"",
""335"",
""3350"",
""3351"",
""3352"",
""3353"",
""3354"",
""3355"",
""3356"",
""3357"",
""3358"",
""3359"",
""336"",
""3360"",
""3361"",
""3362"",
""3363"",
""3364"",
""3365"",
""3366"",
""3367"",
""3368"",
""3369"",
""337"",
""3370"",
""3371"",
""3372"",
""3373"",
""3374"",
""3375"",
""3376"",
""3377"",
""3378"",
""3379"",
""338"",
""3380"",
""3381"",
""3382"",
""3383"",
""3384"",
""3385"",
""3386"",
""3387"",
""3388"",
""3389"",
""339"",
""3390"",
""3391"",
""3392"",
""3393"",
""3394"",
""3395"",
""3396"",
""3397"",
""3398"",
""3399"",
""340"",
""3400"",
""3401"",
""3402"",
""3403"",
""3404"",
""3405"",
""3406"",
""3407"",
""3408"",
""3409"",
""341"",
""3410"",
""3411"",
""3412"",
""3413"",
""3414"",
""3415"",
""3416"",
""3417"",
""3418"",
""3419"",
""342"",
""3420"",
""3421"",
""3422"",
""3423"",
""3424"",
""3425"",
""3426"",
""3427"",
""3428"",
""3429"",
""343"",
""3430"",
""3431"",
""3432"",
""3433"",
""3434"",
""3435"",
""3436"",
""3437"",
""3438"",
""3439"",
""344"",
""3440"",
""3441"",
""3442"",
""3443"",
""3444"",
""3445"",
""3446"",
""3447"",
""3448"",
""3449"",
""345"",
""3450"",
""3451"",
""3452"",
""3453"",
""3454"",
""3455"",
""3456"",
""3457"",
""3458"",
""3459"",
""346"",
""3460"",
""3461"",
""3462"",
""3463"",
""3464"",
""3465"",
""3466"",
""3467"",
""3468"",
""3469"",
""347"",
""3470"",
""3471"",
""3472"",
""3473"",
""3474"",
""3475"",
""3476"",
""3477"",
""3478"",
""3479"",
""348"",
""3480"",
""3481"",
""3482"",
""3483"",
""3484"",
""3485"",
""3486"",
""3487"",
""3488"",
""3489"",
""349"",
""3490"",
""3491"",
""3492"",
""3493"",
""3494"",
""3495"",
""3496"",
""3497"",
""3498"",
""3499"",
""350"",
""3500"",
""3501"",
""3502"",
""3503"",
""3504"",
""3505"",
""3506"",
""3507"",
""3508"",
""3509"",
""351"",
""3510"",
""3511"",
""3512"",
""3513"",
""3514"",
""3515"",
""3516"",
""3517"",
""3518"",
""3519"",
""352"",
""3520"",
""3521"",
""3522"",
""3523"",
""3524"",
""3525"",
""3526"",
""3527"",
""3528"",
""3529"",
""353"",
""3530"",
""3531"",
""3532"",
""3533"",
""3534"",
""3535"",
""3536"",
""3537"",
""3538"",
""3539"",
""354"",
""3540"",
""3541"",
""3542"",
""3543"",
""3544"",
""3545"",
""3546"",
""3547"",
""3548"",
""3549"",
""355"",
""3550"",
""3551"",
""3552"",
""3553"",
""3554"",
""3555"",
""3556"",
""3557"",
""3558"",
""3559"",
""356"",
""3560"",
""3561"",
""3562"",
""3563"",
""3564"",
""3565"",
""3566"",
""3567"",
""3568"",
""3569"",
""357"",
""3570"",
""3571"",
""3572"",
""3573"",
""3574"",
""3575"",
""3576"",
""3577"",
""3578"",
""3579"",
""358"",
""3580"",
""3581"",
""3582"",
""3583"",
""3584"",
""3585"",
""3586"",
""3587"",
""3588"",
""3589"",
""359"",
""3590"",
""3591"",
""3592"",
""3593"",
""3594"",
""3595"",
""3596"",
""3597"",
""3598"",
""3599"",
""360"",
""3600"",
""3601"",
""3602"",
""3603"",
""3604"",
""3605"",
""3606"",
""3607"",
""3608"",
""3609"",
""361"",
""3610"",
""3611"",
""3612"",
""3613"",
""3614"",
""3615"",
""3616"",
""3617"",
""3618"",
""3619"",
""362"",
""3620"",
""3621"",
""3622"",
""3623"",
""3624"",
""3625"",
""3626"",
""3627"",
""3628"",
""3629"",
""363"",
""3630"",
""3631"",
""3632"",
""3633"",
""3634"",
""3635"",
""3636"",
""3637"",
""3638"",
""3639"",
""364"",
""3640"",
""3641"",
""3642"",
""3643"",
""3644"",
""3645"",
""3646"",
""3647"",
""3648"",
""3649"",
""365"",
""3650"",
""3651"",
""3652"",
""3653"",
""3654"",
""3655"",
""3656"",
""3657"",
""3658"",
""3659"",
""366"",
""3660"",
""3661"",
""3662"",
""3663"",
""3664"",
""3665"",
""3666"",
""3667"",
""3668"",
""3669"",
""367"",
""3670"",
""3671"",
""3672"",
""3673"",
""3674"",
""3675"",
""3676"",
""3677"",
""3678"",
""3679"",
""368"",
""3680"",
""3681"",
""3682"",
""3683"",
""3684"",
""3685"",
""3686"",
""3687"",
""3688"",
""3689"",
""369"",
""3690"",
""3691"",
""3692"",
""3693"",
""3694"",
""3695"",
""3696"",
""3697"",
""3698"",
""3699"",
""370"",
""3700"",
""3701"",
""3702"",
""3703"",
""3704"",
""3705"",
""3706"",
""3707"",
""3708"",
""3709"",
""371"",
""3710"",
""3711"",
""3712"",
""3713"",
""3714"",
""3715"",
""3716"",
""3717"",
""3718"",
""3719"",
""372"",
""3720"",
""3721"",
""3722"",
""3723"",
""3724"",
""3725"",
""3726"",
""3727"",
""3728"",
""3729"",
""373"",
""3730"",
""3731"",
""3732"",
""3733"",
""3734"",
""3735"",
""3736"",
""3737"",
""3738"",
""3739"",
""374"",
""3740"",
""3741"",
""3742"",
""3743"",
""3744"",
""3745"",
""3746"",
""3747"",
""3748"",
""3749"",
""375"",
""3750"",
""3751"",
""3752"",
""3753"",
""3754"",
""3755"",
""3756"",
""3757"",
""3758"",
""3759"",
""376"",
""3760"",
""3761"",
""3762"",
""3763"",
""3764"",
""3765"",
""3766"",
""3767"",
""3768"",
""3769"",
""377"",
""3770"",
""3771"",
""3772"",
""3773"",
""3774"",
""3775"",
""3776"",
""3777"",
""3778"",
""3779"",
""378"",
""3780"",
""3781"",
""3782"",
""3783"",
""3784"",
""3785"",
""3786"",
""3787"",
""3788"",
""3789"",
""379"",
""3790"",
""3791"",
""3792"",
""3793"",
""3794"",
""3795"",
""3796"",
""3797"",
""3798"",
""3799"",
""380"",
""3800"",
""3801"",
""3802"",
""3803"",
""3804"",
""3805"",
""3806"",
""3807"",
""3808"",
""3809"",
""381"",
""3810"",
""3811"",
""3812"",
""3813"",
""3814"",
""3815"",
""3816"",
""3817"",
""3818"",
""3819"",
""382"",
""3820"",
""3821"",
""3822"",
""3823"",
""3824"",
""3825"",
""3826"",
""3827"",
""3828"",
""3829"",
""383"",
""3830"",
""3831"",
""3832"",
""3833"",
""3834"",
""3835"",
""3836"",
""3837"",
""3838"",
""3839"",
""384"",
""3840"",
""3841"",
""3842"",
""3843"",
""3844"",
""3845"",
""3846"",
""3847"",
""3848"",
""3849"",
""385"",
""3850"",
""3851"",
""3852"",
""3853"",
""3854"",
""3855"",
""3856"",
""3857"",
""3858"",
""3859"",
""386"",
""3860"",
""3861"",
""3862"",
""3863"",
""3864"",
""3865"",
""3866"",
""3867"",
""3868"",
""3869"",
""387"",
""3870"",
""3871"",
""3872"",
""3873"",
""3874"",
""3875"",
""3876"",
""3877"",
""3878"",
""3879"",
""388"",
""3880"",
""3881"",
""3882"",
""3883"",
""3884"",
""3885"",
""3886"",
""3887"",
""3888"",
""3889"",
""389"",
""3890"",
""3891"",
""3892"",
""3893"",
""3894"",
""3895"",
""3896"",
""3897"",
""3898"",
""3899"",
""390"",
""3900"",
""3901"",
""3902"",
""3903"",
""3904"",
""3905"",
""3906"",
""3907"",
""3908"",
""3909"",
""391"",
""3910"",
""3911"",
""3912"",
""3913"",
""3914"",
""3915"",
""3916"",
""3917"",
""3918"",
""3919"",
""392"",
""3920"",
""3921"",
""3922"",
""3923"",
""3924"",
""3925"",
""3926"",
""3927"",
""3928"",
""3929"",
""393"",
""3930"",
""394"",
""395"",
""396"",
""397"",
""398"",
""399"",
""400"",
""401"",
""402"",
""403"",
""404"",
""405"",
""406"",
""407"",
""408"",
""409"",
""410"",
""411"",
""412"",
""413"",
""414"",
""415"",
""416"",
""417"",
""418"",
""419"",
""420"",
""421"",
""422"",
""423"",
""424"",
""425"",
""426"",
""427"",
""428"",
""429"",
""430"",
""431"",
""432"",
""433"",
""434"",
""435"",
""436"",
""437"",
""438"",
""439"",
""440"",
""441"",
""442"",
""443"",
""444"",
""445"",
""446"",
""447"",
""448"",
""449"",
""450"",
""451"",
""452"",
""453"",
""454"",
""455"",
""456"",
""457"",
""458"",
""459"",
""460"",
""461"",
""462"",
""463"",
""464"",
""465"",
""466"",
""467"",
""468"",
""469"",
""470"",
""471"",
""472"",
""473"",
""474"",
""475"",
""476"",
""477"",
""478"",
""479"",
""480"",
""481"",
""482"",
""483"",
""484"",
""485"",
""486"",
""487"",
""488"",
""489"",
""490"",
""491"",
""492"",
""493"",
""494"",
""495"",
""496"",
""497"",
""498"",
""499"",
""500"",
""5000"",
""5001"",
""501"",
""502"",
""503"",
""504"",
""505"",
""506"",
""507"",
""508"",
""509"",
""510"",
""511"",
""512"",
""513"",
""514"",
""515"",
""516"",
""517"",
""518"",
""519"",
""520"",
""521"",
""522"",
""523"",
""524"",
""525"",
""526"",
""527"",
""528"",
""529"",
""530"",
""531"",
""532"",
""533"",
""534"",
""535"",
""536"",
""537"",
""538"",
""539"",
""540"",
""541"",
""542"",
""543"",
""544"",
""545"",
""546"",
""547"",
""548"",
""549"",
""550"",
""551"",
""552"",
""553"",
""554"",
""555"",
""556"",
""557"",
""558"",
""559"",
""560"",
""561"",
""562"",
""563"",
""564"",
""565"",
""566"",
""567"",
""568"",
""569"",
""570"",
""571"",
""572"",
""573"",
""574"",
""575"",
""576"",
""577"",
""578"",
""579"",
""580"",
""581"",
""582"",
""583"",
""584"",
""585"",
""586"",
""587"",
""588"",
""589"",
""590"",
""591"",
""592"",
""593"",
""594"",
""595"",
""596"",
""597"",
""598"",
""599"",
""600"",
""601"",
""602"",
""603"",
""604"",
""605"",
""606"",
""607"",
""608"",
""609"",
""610"",
""611"",
""612"",
""613"",
""614"",
""615"",
""616"",
""617"",
""618"",
""619"",
""620"",
""621"",
""622"",
""623"",
""624"",
""625"",
""626"",
""627"",
""628"",
""629"",
""630"",
""631"",
""632"",
""633"",
""634"",
""635"",
""636"",
""637"",
""638"",
""639"",
""640"",
""641"",
""642"",
""643"",
""644"",
""645"",
""646"",
""647"",
""648"",
""649"",
""650"",
""651"",
""652"",
""653"",
""654"",
""655"",
""656"",
""657"",
""658"",
""659"",
""660"",
""661"",
""662"",
""663"",
""664"",
""665"",
""666"",
""667"",
""668"",
""669"",
""670"",
""671"",
""672"",
""673"",
""674"",
""675"",
""676"",
""677"",
""678"",
""679"",
""680"",
""681"",
""682"",
""683"",
""684"",
""685"",
""686"",
""687"",
""688"",
""689"",
""690"",
""691"",
""692"",
""693"",
""694"",
""695"",
""696"",
""697"",
""698"",
""699"",
""700"",
""701"",
""702"",
""703"",
""704"",
""705"",
""706"",
""707"",
""708"",
""709"",
""710"",
""711"",
""712"",
""713"",
""714"",
""715"",
""716"",
""717"",
""718"",
""719"",
""720"",
""721"",
""722"",
""723"",
""724"",
""725"",
""726"",
""727"",
""728"",
""729"",
""730"",
""731"",
""732"",
""733"",
""734"",
""735"",
""736"",
""737"",
""738"",
""739"",
""740"",
""741"",
""742"",
""743"",
""744"",
""745"",
""746"",
""747"",
""748"",
""749"",
""750"",
""751"",
""752"",
""753"",
""754"",
""755"",
""756"",
""757"",
""758"",
""759"",
""760"",
""761"",
""762"",
""763"",
""764"",
""765"",
""766"",
""767"",
""768"",
""769"",
""770"",
""771"",
""772"",
""773"",
""774"",
""775"",
""776"",
""777"",
""778"",
""779"",
""780"",
""781"",
""782"",
""783"",
""784"",
""785"",
""786"",
""787"",
""788"",
""789"",
""790"",
""791"",
""792"",
""793"",
""794"",
""795"",
""796"",
""797"",
""798"",
""799"",
""800"",
""801"",
""802"",
""803"",
""804"",
""805"",
""806"",
""807"",
""808"",
""809"",
""810"",
""811"",
""812"",
""813"",
""814"",
""815"",
""816"",
""817"",
""818"",
""819"",
""820"",
""821"",
""822"",
""823"",
""824"",
""825"",
""826"",
""827"",
""828"",
""829"",
""830"",
""831"",
""832"",
""833"",
""834"",
""835"",
""836"",
""837"",
""838"",
""839"",
""840"",
""841"",
""842"",
""843"",
""844"",
""845"",
""846"",
""847"",
""848"",
""849"",
""850"",
""851"",
""852"",
""853"",
""854"",
""855"",
""856"",
""857"",
""858"",
""859"",
""860"",
""861"",
""862"",
""863"",
""864"",
""865"",
""866"",
""867"",
""868"",
""869"",
""870"",
""871"",
""872"",
""873"",
""874"",
""875"",
""876"",
""877"",
""878"",
""879"",
""880"",
""881"",
""882"",
""883"",
""884"",
""885"",
""886"",
""887"",
""888"",
""889"",
""890"",
""891"",
""892"",
""893"",
""894"",
""895"",
""896"",
""897"",
""898"",
""899"",
""900"",
""9000"",
""9001"",
""901"",
""902"",
""903"",
""904"",
""905"",
""906"",
""907"",
""908"",
""909"",
""910"",
""911"",
""912"",
""913"",
""914"",
""915"",
""916"",
""917"",
""918"",
""919"",
""920"",
""921"",
""922"",
""923"",
""924"",
""925"",
""926"",
""927"",
""928"",
""929"",
""930"",
""931"",
""932"",
""933"",
""934"",
""935"",
""936"",
""937"",
""938"",
""939"",
""940"",
""941"",
""942"",
""943"",
""944"",
""945"",
""946"",
""947"",
""948"",
""949"",
""950"",
""951"",
""952"",
""953"",
""954"",
""955"",
""956"",
""957"",
""958"",
""959"",
""960"",
""961"",
""962"",
""963"",
""964"",
""965"",
""966"",
""967"",
""968"",
""969"",
""970"",
""971"",
""972"",
""973"",
""974"",
""975"",
""976"",
""977"",
""978"",
""979"",
""980"",
""981"",
""982"",
""983"",
""984"",
""985"",
""986"",
""987"",
""988"",
""989"",
""990"",
""991"",
""992"",
""993"",
""994"",
""995"",
""996"",
""997"",
""998"",
""999""]";


            #endregion 


            var filesList = Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(files);

            var vault = new EdmVault5();
            vault.LoginAuto("bluebyte", 0);


            var folder = vault.GetFolderFromPath(@"C:\SOLIDWORKS PDM\BLUEBYTESYSTEMS\Bluebyte\api\bayshoresystems\largeset") as IEdmFolder8;

            var filesToAddList = new List<EdmAddFileInfo>();
            var temporaryDirectory = System.IO.Directory.CreateDirectory(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.Diagnostics.Process.GetCurrentProcess().Id.ToString()));

            if (temporaryDirectory.Exists == false)
                temporaryDirectory.Create();
            else
            {
                temporaryDirectory.Delete(true);
                temporaryDirectory.Create();

            }
            foreach (var file in filesList)
            {
                using (var s = System.IO.File.Create($@"{temporaryDirectory.FullName}\{$"{file.Trim()}.sldprt.cvd"}")) 
{

                }
            }

                foreach (var file in filesList)
            {
                filesToAddList.Add(new EdmAddFileInfo()
                {
                   
                    mbsNewName = $"{file.Trim()}.sldprt.cvd",
                    mbsPath = $@"{temporaryDirectory.FullName}\{$"{file.Trim()}.sldprt.cvd"}",

                }); ;
            }

            var filesToAdd = filesToAddList.ToArray();

            var callback = new Callback();


           folder.AddFiles(0, ref filesToAdd, callback);
           


        }

       
    }

    public class Callback : IEdmCallback6
    {
        public void SetProgressRange(int lBarIndex, int lMax)
        {
            Console.WriteLine($"lBarIndex = {lBarIndex} lMax = {lMax}");
        }

        public bool SetProgress(int lBarIndex, int lPos, string bsMsg)
        {

            Console.WriteLine($"lBarIndex = {lBarIndex} - lPos = {lPos} Message = {bsMsg}");
            return true;
        }

        public void SetStatusMessage(int lBarIndex, string bsMessage)
        {
            Console.WriteLine($"lBarIndex = {lBarIndex} bsMessage = {bsMessage}");
        }

        public EdmMBoxResult MsgBox(int lParentWnd, int lMsgID, string bsMsg, EdmMBoxType eType = EdmMBoxType.EdmMbt_OKOnly)
        {
            Console.WriteLine($"Error: {bsMsg}");

            return EdmMBoxResult.EdmMbr_YesAll;
        }

        public void Resolve(int lParentWnd, ref EdmCmdData[] ppoItems)
        {
            for (int i = 0; i < ppoItems.Length; i++)
            {
                var item = ppoItems[i];
            
                var issue = item.mlLongData1;

                if (issue == (int)EdmResolveReason.Edmrr_DstExists  + (int)EdmResolveReason.Edmrr_LockedByYouHere)
                    item.mlLongData2 = (int)EdmResolveAction.Edmra_Skip;
            }
        }
        }
    
}
2 Likes

The callback parameter cannot be null.

1 Like

@AmenJlili great exeml!
Did I understand correctly, that using AddFiles I can’t choose a different folder for adding files, only the one which is initialized in vault.GetFolderFromPath?

Nope. As long as you have iEdmFolder5 you’re gold…