1

我继续收到(找不到路径的一部分 'C:\Users(user profile)\VirtualStore\Program Files (x86)\E!PC\Macros)异常。该目录在驱动器上,但我不确定为什么我会继续收到此异常。

Extra6DestPath = "C:\Users\(user profile)\VirtualStore\Program Files (x86)\E!PC\Macros\"

static void copyMacrosAndBitmaps(string ExtraSourcePath, string Extra6xDestPath )
    {
        //counter for total Macro count on network
        int Count = 0;
        //counter for total bitmap count on network
        int iCount = 0;

        //Get File information to use for copy 
        FileInfo[] macrosArray;
        FileInfo[] iconArray;

        //Get Directory information to use for copy 
        DirectoryInfo di = new DirectoryInfo(ExtraSourcePath);
        DirectoryInfo diIcon = new DirectoryInfo(ExtraIconPath);

        //set all macro paths as a string from directory into an array
        macrosArray = di.GetFiles("*.ebm");
        Count = macrosArray.Length;

        //set all bitmaps from directory into an array
        iconArray = diIcon.GetFiles("*.bmp");
        iCount = iconArray.Length;

        //copy macros into destination folder
        if (Count == 0)
        {
            throw new FileNotFoundException("No Macros found to copy");
        }
        else
        {
            for (int i = 0; i < Count; i++)
            {
                File.Copy(Extra6xSourcePathW7 + macrosArray[i].ToString(), Extra6xDestPath + iconArray[i].Name, true);                
            }
            //Copy the bitmaps into destination folder
            if (iCount == 0)
            {
                throw new FileNotFoundException("No bitmaps found to copy");
            }
            else
            {
                for (int i = 0; i < Count; i++)
                {
                    File.Copy(ExtraIconPath + iconArray[i].ToString(), Extra6xDestPath + iconArray[i].Name, true);
                }
            }
        }
    }
4

1 回答 1

2

我会首先尝试用@符号声明路径,以处理需要转义的字符:

Extra6DestPath = @"C:\Users\(user profile)\VirtualStore\Program Files (x86)\E!PC\Macros\"
于 2013-06-28T21:06:09.710 回答