When I am try to `CreateDirectory` on mapped network drive it show me “Could not find a part of the path”

Refresh

February 2019

Views

7 time

0

I am using System.IO. And I want create folders on mapped network drive which is mapped as Z: drive

I take Array as input and try to create folder structure and I get Could not find a part of the path error

`ApiResult createDirectory(List jackets) {

        string workingDir = @"Z:\Employe Data\Keval\Our FIles\";

        string copyPath = "";

        JacketResponseDTO responseObject = new JacketResponseDTO();
        ApiResult result = new ApiResult();

        try
        {
            jackets.ForEach(jacket =>
            {
                if (!Directory.Exists(workingDir + jacket.partNumber.Substring(0, 1) + "\\" + jacket.partNumber.Substring(0, 1) + "\\" + jacket.partNumber.Substring(1, 3) + "\\" + jacket.partNumber.Substring(4, 12) + "\\" + jacket.revision))
                {


                        DirectoryInfo directoryInfo = Directory.CreateDirectory(workingDir + jacket.partNumber.Substring(0, 1) + "\\" + jacket.partNumber.Substring(0, 1) + "\\" + jacket.partNumber.Substring(1, 3) + "\\" + jacket.partNumber.Substring(4, 12) + "\\" + jacket.revision);
                        copyPath = directoryInfo.FullName + "\\" + jacket.partNumber + " REV " + jacket.revision + ".SLDPRT";



                        responseObject.path.Add(copyPath);

                }
            });
            result.success = true;
            result.data = responseObject;  // return data
            result.message = "Folders created successfully.";

            return result;
        }
        catch (Exception e)
        {
            result.success = false;
            result.message = e.Message.ToString();

            return result;
        }
    }`

0 answers