System.IO File.Copy

So i keep getting this error message when running this code. Could not find a part of the path ‘V:\256\25606P01.pdf’ code is below. Can anyone help me.

error Message.
System.IO.DirectoryNotFoundException: Could not find a part of the path ‘V:\256\25606P01.pdf’.
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
at EFx.GetDrawings.Implementation.GetDrawingsImpl.A001_CustomCodeAction()
at EFx.GetDrawings.Implementation.GetDrawingsImpl.RunStep(Int32 workflowStep)
at Epicor.Functions.FunctionBase3.Run() in C:\_releases\ICE\ICE4.2.200.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 92 at Epicor.Functions.FunctionBase3.Run(TInput input) in C:_releases\ICE\ICE4.2.200.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 75
at Epicor.Functions.FunctionRestAdapter`2.Run(IFunctionRestHost host, JObject input) in C:_releases\ICE\ICE4.2.200.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionRestAdapter.cs:line 49
at Epicor.RESTApi.Functions.Controllers.EpicorFunctionController.Post(Boolean production, String company, String library, String function, JObject data) in C:_releases\ICE\ICE4.2.200.10\Source\Server\Hosting\AspNetCore\RestApi\Epicor.RESTApi.EFxPlugin.AspNetCore\Controllers\EpicorFunctionController.cs:line 71
at lambda_method2399(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

foreach (string file in FileList)
{
   string sourceDirectory = Path.GetDirectoryName(file);
   string fileName = Path.GetFileName(file);
   string sourceFile = Path.Combine(sourceDirectory,fileName);
   string destinationPath = Path.Combine(destinationFolder,fileName);
   File.Copy(sourceFile,destinationPath,true);
}

Does Kinetic app server account have access to V: drive?

Yes it is a mapped network drive and they have access to folder list and i can copy from that file location as the kinetic account running the app server.

try UNC part instead, with

\\server\path

… check, if it makes difference.

1 Like

Network drives are mapped to the user unless you are running your Epicor app under the same user account that the network drive is mapped to it won’t work like Olga said you have to use UNC path but even then you’ll have to give access to the account that runs the IIS app for Epicor

2 Likes

thanks everyone for your help. I have been able to get it work more consistently with UNC paths

2 Likes