访问路径'T:\T Drive.vhd'被拒绝 [英] Access to the path 'T:\T Drive.vhd' is denied

查看:130
本文介绍了访问路径'T:\T Drive.vhd'被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的新服务器编写备份程序。我是管理员,我学到了很多东西。问题是我可以将c:\驱动器上的文件备份到c:\驱动器,但不能备份到SAN上的驱动器,就像我尝试将T驱动器(SAN)上的文件备份到H驱动器(服务器)。我尝试使用像

这样的SetAttributes System.UnauthorizedAccessException:Access to路径被拒绝 [ ^ ]

但它基本上给出了尝试setAttributes的相同错误消息,就像我在尝试复制文件时所做的那样。这是我日志的一部分:



I'm writing a backup program for our new server. I'm an administrator, and I'm learning a lot. The issue is that I can back up a file on the c:\ drive to the c:\ drive, but not for the drives on the SAN, like when I try to backup a file on the T drive (SAN) to the H drive (server). I tried using SetAttributes like
System.UnauthorizedAccessException: Access to the path denied[^]
but it basically gives the same error message to try setAttributes as I did when I tried to copy the file. This is a portion of my log:

12/30/2013 2:14:57 PM Successful backup of file C:\test\iceCreamCake_12_30_2013_1414P.docx
12/30/2013 2:14:57 PM exception during backupSystem.UnauthorizedAccessException: Access to the path 'T:\T Drive.vhd' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes)
   at Bak.BackItUp(String fromDrive, String toDrive) in C:\Users\michele\BackupProj\ServerBackup\ServerBackup\Backup.cs:line 36
12/30/2013 2:14:57 PM exception during backupSystem.UnauthorizedAccessException: Access to the path 'S:\SQL Database.vhd' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes)
   at Bak.BackItUp(String fromDrive, String toDrive) in C:\Users\michele\BackupProj\ServerBackup\ServerBackup\Backup.cs:line 36





如果我以管理员身份登录,我是不是可以运行我的程序进行备份?



这是代码的一部分:





Shouldn't I be able to run my program to do the backup if I'm logged on as Administrator?

Here's part of the code:

try
{
    if (System.IO.File.Exists(fromDrive))
    {
        result = 4;
        if (System.IO.Directory.Exists(toDrive))
        {
            string oldFileName = Path.GetFileName(fromDrive); //file name only
            string sourcePath = Path.GetDirectoryName(fromDrive); //path only
            string newFileName = AppendFileNameWithDate(oldFileName); //file name with date added
            string destFile = System.IO.Path.Combine(toDrive, newFileName); //full path of final destination with new file name
            result = 3;

            System.IO.File.SetAttributes(fromDrive, FileAttributes.Normal);
            System.IO.File.Copy(fromDrive, destFile, true);  //copy backupFileName to toDrive, overwrite destination file if it already exists
            if (File.Exists(destFile))
            {
                Logging.Logging.Instance.Debug("Successful backup of file " + destFile);
                result = 2;
            }
            else
            {
                result = -2;
                Logging.Logging.Instance.Debug("Backup *failure of file " + destFile);
            }

        }
        else
        {
            Logging.Logging.Instance.Debug("to Drive does not exist: " + toDrive);
            result = -1;
        }
    }
    else
    {
        Logging.Logging.Instance.Debug("from Drive does not exist: " + fromDrive);
        result = -1;
    }
}
catch (Exception ex)
{
    Logging.Logging.Instance.Debug("exception during backup" + ex.ToString());
}





目录字符串是这样的:





The directory strings are like this:

string cDrive  = @"C:\backup\2013\iceCreamCake.docx";
string tDrive  =  @"T:\T Drive.vhd";
string sDrive  =  @"S:\SQL Database.vhd";

string cDriveToLocation = @"C:\test";
string tDriveToLocation = @"H:\";
string sDriveToLocation = @"E:\";
string vDriveToLocation = @"G:\";





SAN设置为SAS(不是网络共享或iSCSI),因此它与物理上相同连接硬盘。我们能够打开一个命令窗口,并且可以将t驱动器上的文件复制到h驱动器,因此它只是无法复制/识别路径的代码。我尝试将文件名更改为@T:\ T_Drive.vhd,并尝试将FileAttributes行更改为:System.IO.File.SetAttributes(fromDrive,FileAttributes.System);它仍然提供相同的错误消息。看起来它无法访问文件的路径。



我看了这些链接,但我也有新手问题:

http://stackoverflow.com/questions/1267085/vista-uac-故障映射网络驱动器 [ ^ ]



http://stackoverflow.com/questions/8821410/system-unauthorizedaccessexception-access-to-the-path-denied?lq=1 [ ^ ]



http://stackoverflow.com/questions/6402536/access-to-the-path-xxx-is-denied?rq=1 [ ^ ]



谢谢,

Michele



The SAN is set up as SAS (not network share or iSCSI), so it is the same as a physically connected hard drive. We were able to open a command window and could xcopy the file on the t-drive to the h-drive, so it's just the code that can't do the copy/recognize the path. I tried changing the filename to @"T:\T_Drive.vhd", and also tried changing the FileAttributes line to: System.IO.File.SetAttributes(fromDrive, FileAttributes.System); It still gives the same error message. It looks like it can't access the path to the file.

I looked at these links but I'm having newbie issues too I think:
http://stackoverflow.com/questions/1267085/vista-uac-trouble-mapping-network-drives[^]

http://stackoverflow.com/questions/8821410/system-unauthorizedaccessexception-access-to-the-path-denied?lq=1[^]

http://stackoverflow.com/questions/6402536/access-to-the-path-xxx-is-denied?rq=1[^]

Thanks,
Michele

推荐答案

我打算猜一下你说你可能需要使用UNC路径与映射路径。



这里代替Z:\PlaceIWantToAccess我们经常需要使用\\ TheServer \PlaceIWantToAccess
I'm going to take a guess and say you might need to use the UNC path vs. the mapped path.

Here instead of Z:\PlaceIWantToAccess we often need to use \\TheServer\PlaceIWantToAccess


这篇关于访问路径'T:\T Drive.vhd'被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆