コード例 #1
0
        private bool CreateTargetDirectoryPath(string targetPath)
        {
            // Check for a sub-dir
            int index = targetPath.LastIndexOf("\\");

            if (index != -1 && targetPath[index - 1] != ':')
            {
                string RootDir = targetPath.Substring(0, index);
                if (!CreateTargetDirectoryPath(RootDir))
                {
                    return(false);
                }
            }

            if (mConsoleCopy)
            {
                // Check if it already exists
                if (!XboxUtils.FileExist(targetPath))
                {
                    //
                    if (!XboxUtils.DirectoryCreateVerify(targetPath, false))
                    {
                        // Error
                        MOG_REPORT.ShowMessageBox("Create Target Directory Path", string.Concat(RemapDirectoryString(targetPath), " could not be created!"), MessageBoxButtons.OK);
                        return(false);
                    }

                    XboxUtils.DM_FILE_ATTRIBUTES att = new XboxUtils.DM_FILE_ATTRIBUTES();
                    XboxUtils.GetFileAttributes(targetPath, ref att);
                    if (!(att.SizeHigh != 0 && att.SizeLow != 0))
                    {
                        // Error
                        MOG_REPORT.ShowMessageBox("Create Target Directory Path", string.Concat(RemapDirectoryString(targetPath), " could not be created!"), MessageBoxButtons.OK);
                        return(false);
                    }
                }
            }
            else
            {
                // Check if it already exists
                if (!DosUtils.FileExist(targetPath))
                {
                    //
                    try
                    {
                        Directory.CreateDirectory(targetPath);
                    }
                    catch (Exception e)
                    {
                        // Error
                        MOG_REPORT.ShowMessageBox("Create Directory Error", string.Concat(RemapDirectoryString(targetPath), " could not be created!", "\n", e.ToString()), MessageBoxButtons.OK);
                        return(false);
                    }
                }
            }

            return(true);
        }