question

ahmedsalah-1628 avatar image
0 Votes"
ahmedsalah-1628 asked OlafHelper-2800 commented

System.IO.IOException: 'The network path was not found : '\\10.253.x.xx\ImportExport\testImporter\3'' ?

I work on csharp application when i make shared path and create directory in it it tell me

The network path was not found

so why this issue display

although i can create folder 3 on this path \\10.253.x.xx\ImportExport\testImporter\

but i can't create it from code

code i use it as below

var Pathdirectory=

from debug it have value

 PathDirectory = "\\\\10.253.x.xx\\ImportExport\\testImporter\\3"
 string PathDirectory = myValue1 + "\\" + Month;
 if (!Directory.Exists(PathDirectory))
                 {
    
                     Directory.CreateDirectory(PathDirectory);
    
                 }

exception details

at System.IO.FileSystem.CreateDirectory(String fullPath)
at System.IO.Directory.CreateDirectory(String path)
at Framework.WebApi.Controllers.ZDataDelivery.Z2DeliveryController.Upload() in D:\moved\TestInternalSystemZ2Data\FullProjectAngApiLastUpdate\Z2DataApp\Framework.WebApi\Controllers\ZDataDelivery\Z2DeliveryController.cs:line 123
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()

i can access path above and create folder 3 on it manually

but from code it give me path was not found on network

so why this error display ?





sql-server-generaldotnet-csharpsql-server-transact-sql
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Why did you tagged your post with sql-server; I don't see any relation to, neighter in your code nor in the error message? Please remove it.

0 Votes 0 ·

1 Answer

cooldadtx avatar image
1 Vote"
cooldadtx answered

This is a UNC path which means share security is involved. If you are using a UNC path in your app then the user who is running your app must have read/write permissions to that share in order for you to create a folder within it.

Now looking at your callstack this is a web app. A web app generally runs in a sandbox and doesn't have permission to anything outside its own app directory. If your app needs to be able to write to other directories then you'll need to ensure that the app pool identity that the app is configured to use has write permissions to that UNC path. My guess is that they do not. Note that YOUR identity is not the identity that the web app runs under. So the fact that you can create the folder doesn't really help here because your user account isn't what is trying to do it. Given the specific error you're getting the web app does not have read access to the UNC share and therefore it is failing the call.

You can fix this a couple of different ways. As a test change your app pool to run under your local user account. If it works then it is a permissions issue. Now change the app pool to run under a different user account that has network access and can read/write the UNC share. Then your problem should go away.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.