You are viewing limited content. For full access, please sign in.

Question

Question

save document on mapped network Location

asked on February 3, 2019

Hi Everyone

I am sitting with a request that i need some help with.

 

My Scripting is very basic and needs some expert help. 

 

I am looking to store a PDF from Laserfiche Repository into a Mapped network drive.

 

Is this possible ?

This is what i have currently (SDK Script) and it saves to the local C and D drive but not in my mapped Z: dir. 

"

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;
    using System.IO;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass102
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
           string foldername = TokenReplace("%(foldername)");
           string docname = TokenReplace("%(docname)");
           int id = int.Parse(TokenReplace("%(FindStatement_OutputEntry_ID)"));
           string path = "Z:\\Legal\\NDA's\\";
           DirectoryInfo di = Directory.CreateDirectory(path);
           FileStream streamer = File.Create(path+"\\" + docname +".pdf");
           DocumentExporter doc = new DocumentExporter();
           DocumentInfo docinfo = new DocumentInfo(id,RASession);
           doc.ExportElecDoc(docinfo,streamer);
           docinfo.Dispose();

"

Thanks in advance LF users

Regards

0 0

Answer

SELECTED ANSWER
replied on February 4, 2019

Did you try to give the user under which workflow is running access to the shared folder?  If it doesn't help you can try this https://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User

0 0

Replies

replied on February 4, 2019

Hi Christo, 

Try to use network path (\\machine_name\\shared_path) rather then mapped drive. 

Mapped drive doesn't always work for me. This should work and result is the same.

 

0 0
replied on February 4, 2019

Hi Tomas

 

Thanks, I have done this and then I get that the access is denied, is there some way we can pass authentication through this call? 

 

Thanks
Regards

0 0
SELECTED ANSWER
replied on February 4, 2019

Did you try to give the user under which workflow is running access to the shared folder?  If it doesn't help you can try this https://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User

0 0
replied on February 4, 2019

Thanks Tomas

 

Worked 100%

 

0 0
replied on August 8, 2019

Hi Christo,

I am trying to do this as well.  Are you able to post the entire code?  I was looking at the snippet above, and couldn't find where RASession was declared.

Also, did you end up impersonating the user, or giving access to them to the share drive?

 

Thanks.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.