Visual Basic 2010-拒绝访问 [英] Visual Basic 2010 - Access Denied

查看:153
本文介绍了Visual Basic 2010-拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是编程新手,只工作了几个月.我正在尝试制作一个非常简单的备份程序,该程序备份c:\ users \ dave \ appdata中的所有Appdata文件夹. (窗口7)我尝试了几种方法,包括以下所列:-

1)My.Computer.FileSystem.CopyDirectory("c:\ users \ dave \ APPDATA","d:\ server \ users \ dave \ appdata",覆盖:= True)

尝试此操作时,我拒绝访问路径c:\ users \ dave \ appdata \ roaming \ application data \.
同样,这种方式也可以复制目录名称,但文件夹为空.

2)My.Computer.FileSystem.CopyDirectory("c:\ users \ dave \ appdata \","d:\ server \ users \ dave",FileIO.UIOption.AllDialogs,FileIO.UICancelOption.DoNothing)

3)也尝试使用getfiles和getdirectories,但与数字1相同.

以这种方式执行操作时,它确实允许我访问并进行复制,但会不断出现对话框,提示此操作无法完成,因为文件已打开"等.我希望此操作在晚上在我的计算机上运行,​​并且不希望用户进行交互.

我尝试关闭UAC并选择和取消选择一键,但仍然无法使其正常工作.我也知道我的文档"未复制的问题,因为它实际上称为文档".

我可以使用DOS Xcopy,但是它击败了我确实想要一个不错的GUI且根本不想使用DOS的对象.

对不起,详细的解释!希望有人能提供帮助,因为我已经尽力尝试了一切,并且一发不可收拾!!!!

预先感谢Dave.

Hi there , I am new to programming only been doing it for a few months. I am attempting to make a very easy backup program that backs up all of Appdata folder in c:\users\dave\appdata. ( window 7 ) I have tried several ways including listed below :-

1) My.Computer.FileSystem.CopyDirectory("c:\users\dave\APPDATA", "d:\server\users\dave\appdata", overwrite:=True)

When trying this i get " access to path c:\users\dave\appdata\roaming\application data\ is denied.
Also this way does copy the directory name but folders are empty.

2) My.Computer.FileSystem.CopyDirectory("c:\users\dave\appdata\", "d:\server\users\dave", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)

3) Also tried getfiles & getdirectories but does the same as number 1.

When doing it this way it does allow me access and does copy but keep getting dialogs saying " this action can not be complete because the file is open " etc. I wanted this to run at night on my computers at work and didnt want user interaction.

I have tried turning UAC off and selecting and de-selecting one click but still cant get it to work. I am also aware of the issues with "My documents " not copying because its actually called " Documents ".

I could use DOS Xcopy but it defeats the object i realy wanted a nice GUI and didnt want to use DOS at all.

Sorry for the long explanation !!!!! Hopefully someone can help as i have tried everything within my power and am out of steam !!!

Thanks in advance, Dave.

推荐答案



复制正在使用的文件的一种简单解决方案是使用卷影复制.

看看这篇文章,它将向您解释如何做.

来自.NET的卷影副本 [
Hi,

An easy solution to copy files that are in use is to use Shadow Copy.

Have a look at this article it will explain you how to do it.

Volume Shadow Copies from .NET[^]

Good luck ;)

Valery.


我的建议是购买Acronis TrueImage Home,并让它执行您的每晚备份.
My advice is to buy Acronis TrueImage Home, and do let that perform your nightly backups. It''s relatively inexpensive at


50相对便宜,您只需设置它就可以了.它会执行您可能需要的任何类型的备份,并节省数百小时的时间来尝试弄清楚如何使自己的代码执行.

我有它,而且真是太棒了.
50, and you can just set it and forget it. It''ll perform any kind of backup you might require, and save your hundreds of hours of time trying to figure out how to make your own code do it.

I have it, and it''s just freakin great.


这篇关于Visual Basic 2010-拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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