示例#1
0
 private static string InternalCopy(string fullSourceFileName, string fullDestFileName, string sourceFileName, string destFileName, bool overwrite)
 {
     fullSourceFileName = Path.AddLongPathPrefix(fullSourceFileName);
     fullDestFileName   = Path.AddLongPathPrefix(fullDestFileName);
     if (!Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite))
     {
         int    lastWin32Error = Marshal.GetLastWin32Error();
         string maybeFullPath  = destFileName;
         if (lastWin32Error != 80)
         {
             using (SafeFileHandle file = Win32Native.UnsafeCreateFile(fullSourceFileName, int.MinValue, FileShare.Read, (Win32Native.SECURITY_ATTRIBUTES)null, FileMode.Open, 0, IntPtr.Zero))
             {
                 if (file.IsInvalid)
                 {
                     maybeFullPath = sourceFileName;
                 }
             }
             if (lastWin32Error == 5 && LongPathDirectory.InternalExists(fullDestFileName))
             {
                 throw new IOException(Environment.GetResourceString("Arg_FileIsDirectory_Name", (object)destFileName), 5, fullDestFileName);
             }
         }
         __Error.WinIOError(lastWin32Error, maybeFullPath);
     }
     return(fullDestFileName);
 }
示例#2
0
 internal static string GetDirectoryName(string path)
 {
     if (path != null)
     {
         bool   removed;
         string path1 = LongPath.TryRemoveLongPathPrefix(path, out removed);
         Path.CheckInvalidPathChars(path1, false);
         path = LongPath.NormalizePath(path1, false);
         int rootLength = LongPath.GetRootLength(path1);
         if (path1.Length > rootLength)
         {
             int length = path1.Length;
             if (length == rootLength)
             {
                 return((string)null);
             }
             do
             {
                 ;
             }while (length > rootLength && (int)path1[--length] != (int)Path.DirectorySeparatorChar && (int)path1[length] != (int)Path.AltDirectorySeparatorChar);
             string path2 = path1.Substring(0, length);
             if (removed)
             {
                 path2 = Path.AddLongPathPrefix(path2);
             }
             return(path2);
         }
     }
     return((string)null);
 }
示例#3
0
        private static void InternalDelete(string fullPath, string userPath, bool recursive)
        {
            string demandDir = GetDemandDir(fullPath, !recursive);

            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { demandDir }, false, false).Demand();
            string path = Path.AddLongPathPrefix(fullPath);

            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int errorCode = File.FillAttributeInfo(path, ref data, false, true);

            switch (errorCode)
            {
            case 0:
                goto Label_0051;

            case 2:
                errorCode = 3;
                break;
            }
            __Error.WinIOError(errorCode, fullPath);
Label_0051:
            if ((data.fileAttributes & 0x400) != 0)
            {
                recursive = false;
            }
            DeleteHelper(path, userPath, recursive);
        }
        internal static String GetDirectoryName(String path)
        {
            if (path != null)
            {
                bool   removedPrefix;
                String tempPath = TryRemoveLongPathPrefix(path, out removedPrefix);

                Path.CheckInvalidPathChars(tempPath);
                path = NormalizePath(tempPath, false);
                int root = GetRootLength(tempPath);
                int i    = tempPath.Length;
                if (i > root)
                {
                    i = tempPath.Length;
                    if (i == root)
                    {
                        return(null);
                    }
                    while (i > root && tempPath[--i] != Path.DirectorySeparatorChar && tempPath[i] != Path.AltDirectorySeparatorChar)
                    {
                        ;
                    }
                    String result = tempPath.Substring(0, i);
                    if (removedPrefix)
                    {
                        result = Path.AddLongPathPrefix(result);
                    }

                    return(result);
                }
            }
            return(null);
        }
        internal static bool InternalExists(String path, out int lastError)
        {
            Contract.Requires(path != null);
            String tempPath = Path.AddLongPathPrefix(path);

            return(Directory.InternalExists(tempPath, out lastError));
        }
示例#6
0
 internal static string GetDirectoryName(string path)
 {
     if (path != null)
     {
         bool   flag;
         string text = LongPath.TryRemoveLongPathPrefix(path, out flag);
         Path.CheckInvalidPathChars(text, false);
         path = LongPath.NormalizePath(text, false);
         int rootLength = LongPath.GetRootLength(text);
         int num        = text.Length;
         if (num > rootLength)
         {
             num = text.Length;
             if (num == rootLength)
             {
                 return(null);
             }
             while (num > rootLength && text[--num] != Path.DirectorySeparatorChar && text[num] != Path.AltDirectorySeparatorChar)
             {
             }
             string text2 = text.Substring(0, num);
             if (flag)
             {
                 text2 = Path.AddLongPathPrefix(text2);
             }
             return(text2);
         }
     }
     return(null);
 }
 internal static string GetDirectoryName(string path)
 {
     if (path != null)
     {
         bool   flag;
         string str = TryRemoveLongPathPrefix(path, out flag);
         Path.CheckInvalidPathChars(str);
         path = NormalizePath(str, false);
         int rootLength = GetRootLength(str);
         if (str.Length > rootLength)
         {
             int length = str.Length;
             if (length == rootLength)
             {
                 return(null);
             }
             while (((length > rootLength) && (str[--length] != Path.DirectorySeparatorChar)) && (str[length] != Path.AltDirectorySeparatorChar))
             {
             }
             string str2 = str.Substring(0, length);
             if (flag)
             {
                 str2 = Path.AddLongPathPrefix(str2);
             }
             return(str2);
         }
     }
     return(null);
 }
        internal static void Delete(String path)
        {
            Contract.Requires(path != null);

            String fullPath = LongPath.NormalizePath(path);

            // For security check, path should be resolved to an absolute path.
            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { fullPath }, false, false).Demand();

            String tempPath = Path.AddLongPathPrefix(fullPath);
            bool   r        = Win32Native.DeleteFile(tempPath);

            if (!r)
            {
                int hr = Marshal.GetLastWin32Error();
                if (hr == Win32Native.ERROR_FILE_NOT_FOUND)
                {
                    return;
                }
                else
                {
                    __Error.WinIOError(hr, fullPath);
                }
            }
        }
        internal static bool InternalExists(String path)
        {
            Contract.Requires(path != null);
            String tempPath = Path.AddLongPathPrefix(path);

            return(File.InternalExists(tempPath));
        }
        internal static void Move(String sourceFileName, String destFileName)
        {
            Contract.Requires(sourceFileName != null);
            Contract.Requires(destFileName != null);
            Contract.Requires(sourceFileName.Length > 0);
            Contract.Requires(destFileName.Length > 0);

            String fullSourceFileName = LongPath.NormalizePath(sourceFileName);

            new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read, new String[] { fullSourceFileName }, false, false).Demand();
            String fullDestFileName = LongPath.NormalizePath(destFileName);

            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { fullDestFileName }, false, false).Demand();

            if (!LongPathFile.InternalExists(fullSourceFileName))
            {
                __Error.WinIOError(Win32Native.ERROR_FILE_NOT_FOUND, fullSourceFileName);
            }

            String tempSourceFileName = Path.AddLongPathPrefix(fullSourceFileName);
            String tempDestFileName   = Path.AddLongPathPrefix(fullDestFileName);

            if (!Win32Native.MoveFile(tempSourceFileName, tempDestFileName))
            {
                __Error.WinIOError();
            }
        }
 private static string InternalCopy(string fullSourceFileName, string fullDestFileName, string sourceFileName, string destFileName, bool overwrite)
 {
     fullSourceFileName = Path.AddLongPathPrefix(fullSourceFileName);
     fullDestFileName   = Path.AddLongPathPrefix(fullDestFileName);
     if (!Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite))
     {
         int    errorCode     = Marshal.GetLastWin32Error();
         string maybeFullPath = destFileName;
         if (errorCode != 80)
         {
             using (SafeFileHandle handle = Win32Native.UnsafeCreateFile(fullSourceFileName, -2147483648, FileShare.Read, null, FileMode.Open, 0, IntPtr.Zero))
             {
                 if (handle.IsInvalid)
                 {
                     maybeFullPath = sourceFileName;
                 }
             }
             if ((errorCode == 5) && LongPathDirectory.InternalExists(fullDestFileName))
             {
                 throw new IOException(Environment.GetResourceString("Arg_FileIsDirectory_Name", new object[] { destFileName }), 5, fullDestFileName);
             }
         }
         __Error.WinIOError(errorCode, maybeFullPath);
     }
     return(fullDestFileName);
 }
示例#12
0
        internal static long GetLength(string path)
        {
            string path1 = LongPath.NormalizePath(path);

            new FileIOPermission(FileIOPermissionAccess.Read, new string[1] {
                path1
            }, 0 != 0, 0 != 0).Demand();
            string path2 = Path.AddLongPathPrefix(path1);

            Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileAttributeData = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA& data = @fileAttributeData;
            int num1      = 0;
            int num2      = 1;
            int errorCode = File.FillAttributeInfo(path2, data, num1 != 0, num2 != 0);

            if (errorCode != 0)
            {
                __Error.WinIOError(errorCode, path);
            }
            if ((fileAttributeData.fileAttributes & 16) != 0)
            {
                __Error.WinIOError(2, path);
            }
            return((long)fileAttributeData.fileSizeHigh << 32 | (long)fileAttributeData.fileSizeLow & (long)uint.MaxValue);
        }
        internal static void Move(String sourceDirName, String destDirName)
        {
            Contract.Requires(sourceDirName != null);
            Contract.Requires(destDirName != null);
            Contract.Requires(sourceDirName.Length != 0);
            Contract.Requires(destDirName.Length != 0);

            String fullsourceDirName = LongPath.NormalizePath(sourceDirName);
            String sourcePath        = GetDemandDir(fullsourceDirName, false);

            if (sourcePath.Length >= Path.MaxLongPath)
            {
                throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
            }

            String fulldestDirName = LongPath.NormalizePath(destDirName);
            String destPath        = GetDemandDir(fulldestDirName, false);

            if (destPath.Length >= Path.MaxLongPath)
            {
                throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
            }

            new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read, new String[] { sourcePath }, false, false).Demand();
            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { destPath }, false, false).Demand();

            if (String.Compare(sourcePath, destPath, StringComparison.OrdinalIgnoreCase) == 0)
            {
                throw new IOException(Environment.GetResourceString("IO.IO_SourceDestMustBeDifferent"));
            }

            String sourceRoot      = LongPath.GetPathRoot(sourcePath);
            String destinationRoot = LongPath.GetPathRoot(destPath);

            if (String.Compare(sourceRoot, destinationRoot, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new IOException(Environment.GetResourceString("IO.IO_SourceDestMustHaveSameRoot"));
            }


            String tempSourceDirName = Path.AddLongPathPrefix(sourceDirName);
            String tempDestDirName   = Path.AddLongPathPrefix(destDirName);

            if (!Win32Native.MoveFile(tempSourceDirName, tempDestDirName))
            {
                int hr = Marshal.GetLastWin32Error();
                if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // Source dir not found
                {
                    hr = Win32Native.ERROR_PATH_NOT_FOUND;
                    __Error.WinIOError(hr, fullsourceDirName);
                }
                // This check was originally put in for Win9x (unfortunately without special casing it to be for Win9x only). We can't change the NT codepath now for backcomp reasons.
                if (hr == Win32Native.ERROR_ACCESS_DENIED) // WinNT throws IOException. This check is for Win9x. We can't change it for backcomp.
                {
                    throw new IOException(Environment.GetResourceString("UnauthorizedAccess_IODenied_Path", sourceDirName), Win32Native.MakeHRFromErrorCode(hr));
                }
                __Error.WinIOError(hr, String.Empty);
            }
        }
示例#14
0
        internal static string InternalCombine(string path1, string path2)
        {
            bool   removed;
            string path = Path.InternalCombine(LongPath.TryRemoveLongPathPrefix(path1, out removed), path2);

            if (removed)
            {
                path = Path.AddLongPathPrefix(path);
            }
            return(path);
        }
        internal static string InternalCombine(string path1, string path2)
        {
            bool   flag;
            string path = Path.InternalCombine(TryRemoveLongPathPrefix(path1, out flag), path2);

            if (flag)
            {
                path = Path.AddLongPathPrefix(path);
            }
            return(path);
        }
示例#16
0
        // Token: 0x06001ADF RID: 6879 RVA: 0x0005A51C File Offset: 0x0005871C
        internal static string InternalCombine(string path1, string path2)
        {
            bool   flag;
            string path3 = LongPath.TryRemoveLongPathPrefix(path1, out flag);
            string text  = Path.InternalCombine(path3, path2);

            if (flag)
            {
                text = Path.AddLongPathPrefix(text);
            }
            return(text);
        }
示例#17
0
        internal unsafe bool TryExpandShortFileName()
        {
            if (this.useStackAlloc)
            {
                this.NullTerminate();
                char *chPtr          = this.UnsafeGetArrayPtr();
                char *longPathBuffer = (char *)stackalloc byte[(((IntPtr)(Path.MaxPath + 1)) * 2)];
                int   len            = Win32Native.GetLongPathName(chPtr, longPathBuffer, Path.MaxPath);
                if (len >= Path.MaxPath)
                {
                    throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
                }
                if (len == 0)
                {
                    return(false);
                }
                Buffer.memcpy(longPathBuffer, 0, chPtr, 0, len);
                this.Length = len;
                this.NullTerminate();
                return(true);
            }
            StringBuilder stringBuilder = this.GetStringBuilder();
            string        str           = stringBuilder.ToString();
            string        path          = str;
            bool          flag          = false;

            if (path.Length > Path.MaxPath)
            {
                path = Path.AddLongPathPrefix(path);
                flag = true;
            }
            stringBuilder.Capacity = this.m_capacity;
            stringBuilder.Length   = 0;
            int num2 = Win32Native.GetLongPathName(path, stringBuilder, this.m_capacity);

            if (num2 == 0)
            {
                stringBuilder.Length = 0;
                stringBuilder.Append(str);
                return(false);
            }
            if (flag)
            {
                num2 -= 4;
            }
            if (num2 >= this.m_maxPath)
            {
                throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
            }
            stringBuilder = Path.RemoveLongPathPrefix(stringBuilder);
            this.Length   = stringBuilder.Length;
            return(true);
        }
        internal static void Delete(string path)
        {
            string str = LongPath.NormalizePath(path);

            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { str }, false, false).Demand();
            if (!Win32Native.DeleteFile(Path.AddLongPathPrefix(str)))
            {
                int errorCode = Marshal.GetLastWin32Error();
                if (errorCode != 2)
                {
                    __Error.WinIOError(errorCode, str);
                }
            }
        }
示例#19
0
        internal static string GetPathRoot(string path)
        {
            if (path == null)
            {
                return((string)null);
            }
            bool   removed;
            string path1 = LongPath.NormalizePath(LongPath.TryRemoveLongPathPrefix(path, out removed), false);
            string path2 = path.Substring(0, LongPath.GetRootLength(path1));

            if (removed)
            {
                path2 = Path.AddLongPathPrefix(path2);
            }
            return(path2);
        }
示例#20
0
        internal static void Move(string sourceDirName, string destDirName)
        {
            string fullPath  = LongPath.NormalizePath(sourceDirName);
            string demandDir = GetDemandDir(fullPath, false);

            if (demandDir.Length >= Path.MaxLongPath)
            {
                throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
            }
            string strB = GetDemandDir(LongPath.NormalizePath(destDirName), false);

            if (strB.Length >= Path.MaxLongPath)
            {
                throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
            }
            new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read, new string[] { demandDir }, false, false).Demand();
            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { strB }, false, false).Demand();
            if (string.Compare(demandDir, strB, StringComparison.OrdinalIgnoreCase) == 0)
            {
                throw new IOException(Environment.GetResourceString("IO.IO_SourceDestMustBeDifferent"));
            }
            string pathRoot = LongPath.GetPathRoot(demandDir);
            string str6     = LongPath.GetPathRoot(strB);

            if (string.Compare(pathRoot, str6, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new IOException(Environment.GetResourceString("IO.IO_SourceDestMustHaveSameRoot"));
            }
            string src = Path.AddLongPathPrefix(sourceDirName);
            string dst = Path.AddLongPathPrefix(destDirName);

            if (!Win32Native.MoveFile(src, dst))
            {
                int errorCode = Marshal.GetLastWin32Error();
                switch (errorCode)
                {
                case 2:
                    errorCode = 3;
                    __Error.WinIOError(errorCode, fullPath);
                    break;

                case 5:
                    throw new IOException(Environment.GetResourceString("UnauthorizedAccess_IODenied_Path", new object[] { sourceDirName }), Win32Native.MakeHRFromErrorCode(errorCode));
                }
                __Error.WinIOError(errorCode, string.Empty);
            }
        }
        internal static string GetPathRoot(string path)
        {
            bool flag;

            if (path == null)
            {
                return(null);
            }
            string str  = NormalizePath(TryRemoveLongPathPrefix(path, out flag), false);
            string str2 = path.Substring(0, GetRootLength(str));

            if (flag)
            {
                str2 = Path.AddLongPathPrefix(str2);
            }
            return(str2);
        }
示例#22
0
        internal static void Delete(string path)
        {
            string text = LongPath.NormalizePath(path);

            FileIOPermission.QuickDemand(FileIOPermissionAccess.Write, text, false, false);
            string path2 = Path.AddLongPathPrefix(text);

            if (!Win32Native.DeleteFile(path2))
            {
                int lastWin32Error = Marshal.GetLastWin32Error();
                if (lastWin32Error == 2)
                {
                    return;
                }
                __Error.WinIOError(lastWin32Error, text);
            }
        }
示例#23
0
        internal static string GetPathRoot(string path)
        {
            if (path == null)
            {
                return(null);
            }
            bool   flag;
            string path2 = LongPath.TryRemoveLongPathPrefix(path, out flag);

            path2 = LongPath.NormalizePath(path2, false);
            string text = path.Substring(0, LongPath.GetRootLength(path2));

            if (flag)
            {
                text = Path.AddLongPathPrefix(text);
            }
            return(text);
        }
示例#24
0
        internal static DateTimeOffset GetLastWriteTime(string path)
        {
            string text = LongPath.NormalizePath(path);

            FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, text, false, false);
            string path2 = Path.AddLongPathPrefix(text);

            Win32Native.WIN32_FILE_ATTRIBUTE_DATA win32_FILE_ATTRIBUTE_DATA = default(Win32Native.WIN32_FILE_ATTRIBUTE_DATA);
            int num = File.FillAttributeInfo(path2, ref win32_FILE_ATTRIBUTE_DATA, false, false);

            if (num != 0)
            {
                __Error.WinIOError(num, text);
            }
            DateTime dateTime = DateTime.FromFileTimeUtc(win32_FILE_ATTRIBUTE_DATA.ftLastWriteTime.ToTicks()).ToLocalTime();

            return(new DateTimeOffset(dateTime).ToLocalTime());
        }
        internal static String InternalCombine(String path1, String path2)
        {
            Contract.Requires(path1 != null);
            Contract.Requires(path2 != null);
            Contract.Requires(path2.Length != 0);
            Contract.Requires(!IsPathRooted(path2));

            bool   removedPrefix;
            String tempPath1 = TryRemoveLongPathPrefix(path1, out removedPrefix);

            String tempResult = Path.InternalCombine(tempPath1, path2);

            if (removedPrefix)
            {
                tempResult = Path.AddLongPathPrefix(tempResult);
            }
            return(tempResult);
        }
示例#26
0
        internal static void Delete(string path)
        {
            string str = LongPath.NormalizePath(path);

            new FileIOPermission(FileIOPermissionAccess.Write, new string[1] {
                str
            }, 0 != 0, 0 != 0).Demand();
            if (Win32Native.DeleteFile(Path.AddLongPathPrefix(str)))
            {
                return;
            }
            int lastWin32Error = Marshal.GetLastWin32Error();

            if (lastWin32Error == 2)
            {
                return;
            }
            __Error.WinIOError(lastWin32Error, str);
        }
        private static String InternalCopy(String fullSourceFileName, String fullDestFileName, String sourceFileName, String destFileName, bool overwrite)
        {
            Contract.Requires(fullSourceFileName != null);
            Contract.Requires(fullDestFileName != null);
            Contract.Requires(fullSourceFileName.Length > 0);
            Contract.Requires(fullDestFileName.Length > 0);

            fullSourceFileName = Path.AddLongPathPrefix(fullSourceFileName);
            fullDestFileName   = Path.AddLongPathPrefix(fullDestFileName);
            bool r = Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite);

            if (!r)
            {
                // Save Win32 error because subsequent checks will overwrite this HRESULT.
                int    errorCode = Marshal.GetLastWin32Error();
                String fileName  = destFileName;

                if (errorCode != Win32Native.ERROR_FILE_EXISTS)
                {
                    // For a number of error codes (sharing violation, path
                    // not found, etc) we don't know if the problem was with
                    // the source or dest file.  Try reading the source file.
                    using (SafeFileHandle handle = Win32Native.UnsafeCreateFile(fullSourceFileName, FileStream.GENERIC_READ, FileShare.Read, null, FileMode.Open, 0, IntPtr.Zero)) {
                        if (handle.IsInvalid)
                        {
                            fileName = sourceFileName;
                        }
                    }

                    if (errorCode == Win32Native.ERROR_ACCESS_DENIED)
                    {
                        if (LongPathDirectory.InternalExists(fullDestFileName))
                        {
                            throw new IOException(Environment.GetResourceString("Arg_FileIsDirectory_Name", destFileName), Win32Native.ERROR_ACCESS_DENIED, fullDestFileName);
                        }
                    }
                }

                __Error.WinIOError(errorCode, fileName);
            }

            return(fullDestFileName);
        }
        internal static String GetPathRoot(String path)
        {
            if (path == null)
            {
                return(null);
            }

            bool   removedPrefix;
            String tempPath = TryRemoveLongPathPrefix(path, out removedPrefix);

            tempPath = NormalizePath(tempPath, false);
            String result = path.Substring(0, GetRootLength(tempPath));

            if (removedPrefix)
            {
                result = Path.AddLongPathPrefix(result);
            }
            return(result);
        }
        internal static DateTimeOffset GetCreationTime(string path)
        {
            string str = LongPath.NormalizePath(path);

            new FileIOPermission(FileIOPermissionAccess.Read, new string[] { str }, false, false).Demand();
            string str2 = Path.AddLongPathPrefix(str);

            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int errorCode = File.FillAttributeInfo(str2, ref data, false, false);

            if (errorCode != 0)
            {
                __Error.WinIOError(errorCode, str);
            }
            long           fileTime = (data.ftCreationTimeHigh << 0x20) | data.ftCreationTimeLow;
            DateTimeOffset offset   = new DateTimeOffset(DateTime.FromFileTimeUtc(fileTime).ToLocalTime());

            return(offset.ToLocalTime());
        }
        internal static void Move(string sourceFileName, string destFileName)
        {
            string path = LongPath.NormalizePath(sourceFileName);

            new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read, new string[] { path }, false, false).Demand();
            string str2 = LongPath.NormalizePath(destFileName);

            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { str2 }, false, false).Demand();
            if (!InternalExists(path))
            {
                __Error.WinIOError(2, path);
            }
            string src = Path.AddLongPathPrefix(path);
            string dst = Path.AddLongPathPrefix(str2);

            if (!Win32Native.MoveFile(src, dst))
            {
                __Error.WinIOError();
            }
        }