Esempio n. 1
0
        internal static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory)
        {
            string pathToTargetFullPath = PathInternal.GetLinkTargetFullPath(path, pathToTarget);

            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
            int errorCode = FillAttributeInfo(pathToTargetFullPath, ref data, returnErrorOnNotFound: true);

            if (errorCode == Interop.Errors.ERROR_SUCCESS &&
                data.dwFileAttributes != -1 &&
                isDirectory != ((data.dwFileAttributes & Interop.Kernel32.FileAttributes.FILE_ATTRIBUTE_DIRECTORY) != 0))
            {
                throw new IOException(SR.Format(SR.IO_InconsistentLinkType, path));
            }

            Interop.Kernel32.CreateSymbolicLink(path, pathToTarget, isDirectory);
        }
Esempio n. 2
0
        internal static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory)
        {
            string pathToTargetFullPath = PathInternal.GetLinkTargetFullPath(path, pathToTarget);

            Interop.Kernel32.CreateSymbolicLink(path, pathToTarget, isDirectory);
        }