Strange Access Denied Problem with Windows 7

I got a new computer about six months ago that came with Windows Vista
Home Premium 64bit. Before that I had done all of my .NET development
either on an XP Pro VM or my former XP Pro computer at home. Shortly
after getting my new computer at home, I also got a license for VMWare
to be able to test my software on multiple platforms and
configurations.

I had wrote an application originally in VB.NET that was a simple
backup utility. It supports mutiple backup configurations. Any given
copnfiguration would define a backup which would be a list of files to
backup, a list of folders to backup and a target device and target
folder. It's a little more complicated than that but those are the
basics.

When a backup is run the user has the option to delete all files at
the target location, then after deleting them it copys all files and
folders specified to the target folder on the target device.

I am now converting this application to C#.NET in a Windows 7 64bit
VM. I ran into some strange access denied problems when trying to copy
files. At first I thought it was a Windows 7/Vista issue. I found out
how to install the application so that when it runs the user is asked
for administrator permission to run. But the problem turned out to be
more sinister.

I found that the problem is only with Windows 7, it doesn't happen on
Vista. IF you have a Windows Explorer window open and have selected
the target folder for the backup, THAT is what causes the access
denied problem. If you just leave Windows Explorer closed, then there
is never an access denied problem.

PLUS, I can switch over to the Windows Explorer window and delete the
file just fine by pointing and clicking.

Any ideas?
0
Joe
2/25/2010 9:25:59 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

2 Replies
1016 Views

Similar Articles

[PageSpeed] 11

Joe Cool wrote:
> [...]
> I am now converting this application to C#.NET in a Windows 7 64bit
> VM. I ran into some strange access denied problems when trying to copy
> files. At first I thought it was a Windows 7/Vista issue. I found out
> how to install the application so that when it runs the user is asked
> for administrator permission to run. But the problem turned out to be
> more sinister.
> 
> I found that the problem is only with Windows 7, it doesn't happen on
> Vista. IF you have a Windows Explorer window open and have selected
> the target folder for the backup, THAT is what causes the access
> denied problem. If you just leave Windows Explorer closed, then there
> is never an access denied problem.
> 
> PLUS, I can switch over to the Windows Explorer window and delete the
> file just fine by pointing and clicking.
> 
> Any ideas?

I haven't tested it extensively, but it sounds like Windows Explorer is 
simply keeping a lock on the folder when it's selected.  Which makes 
some sense, in an awkward sort of way.

Personally, it's my opinion that Explorer should not stand in the way of 
normal uses of the file system.  It's there to provide a view on the 
current state of the file system, and to do so without interfering with 
the proper operation of other programs that use the file system.

But, to the extent that Windows Explorer can't do that job without doing 
at least _some_ locking on the file system, there will always be cases 
where activity in Explorer affects other programs.

For example, when you select a folder, Explorer (eventually) reports the 
total size of the folder, which it do only by traversing the contents, 
and while examining the contents may lock something, which implicitly 
locks the entire sub-tree of the file system.

And depending on the extent to which Microsoft has decided to make 
Explorer a more active "explorer", it will necessarily wind up doing 
more locking.  That aspect being a subjective choice in the 
implementation of Explorer � the trade-off between Windows Explorer 
being non-intrusive and it being able to present all the information to 
the user that Microsoft wants it to � it's something that can easily 
vary from one version of the OS to another.

For the specific question: it seems to me you could just delete the 
_contents_ of the target folder, rather than the whole folder.  You'll 
still run the risk of something in the folder not being able to be 
deleted, but the finer the granularity of the deletion, the lower the 
odds of a problem.

Alternatively, you can just include in your error reporting to the user 
a suggestion that they close any windows for applications that might be 
using a file or folder that failed to delete, including windows in 
Windows Explorer (you may need to do that anyway, since the underlying 
problem is intractable�there will always be ways for the access 
violation to occur).

Pete
0
Peter
2/25/2010 9:48:21 PM
On Feb 25, 4:48=A0pm, Peter Duniho <no.peted.s...@no.nwlink.spam.com>
wrote:
> Joe Cool wrote:
> > [...]
> > I am now converting this application to C#.NET in a Windows 7 64bit
> > VM. I ran into some strange access denied problems when trying to copy
> > files. At first I thought it was a Windows 7/Vista issue. I found out
> > how to install the application so that when it runs the user is asked
> > for administrator permission to run. But the problem turned out to be
> > more sinister.
>
> > I found that the problem is only with Windows 7, it doesn't happen on
> > Vista. IF you have a Windows Explorer window open and have selected
> > the target folder for the backup, THAT is what causes the access
> > denied problem. If you just leave Windows Explorer closed, then there
> > is never an access denied problem.
>
> > PLUS, I can switch over to the Windows Explorer window and delete the
> > file just fine by pointing and clicking.
>
> > Any ideas?
>
> I haven't tested it extensively, but it sounds like Windows Explorer is
> simply keeping a lock on the folder when it's selected. =A0Which makes
> some sense, in an awkward sort of way.

That is my suspicion.

>
> Personally, it's my opinion that Explorer should not stand in the way of
> normal uses of the file system. =A0It's there to provide a view on the
> current state of the file system, and to do so without interfering with
> the proper operation of other programs that use the file system.

Agreed.

>
> But, to the extent that Windows Explorer can't do that job without doing
> at least _some_ locking on the file system, there will always be cases
> where activity in Explorer affects other programs.
>
> For example, when you select a folder, Explorer (eventually) reports the
> total size of the folder, which it do only by traversing the contents,
> and while examining the contents may lock something, which implicitly
> locks the entire sub-tree of the file system.
>
> And depending on the extent to which Microsoft has decided to make
> Explorer a more active "explorer", it will necessarily wind up doing
> more locking. =A0That aspect being a subjective choice in the
> implementation of Explorer the trade-off between Windows Explorer
> being non-intrusive and it being able to present all the information to
> the user that Microsoft wants it to it's something that can easily
> vary from one version of the OS to another.
>
> For the specific question: it seems to me you could just delete the
> _contents_ of the target folder, rather than the whole folder. =A0You'll
> still run the risk of something in the folder not being able to be
> deleted, but the finer the granularity of the deletion, the lower the
> odds of a problem.

Actually the exception being thrown does mention a problem with a
specific file, the entire process of deleting the target folders and
files is by deleting the main backup folder a la:

Directory.Delete(pathToBackupFolder);

>
> Alternatively, you can just include in your error reporting to the user
> a suggestion that they close any windows for applications that might be
> using a file or folder that failed to delete, including windows in
> Windows Explorer (you may need to do that anyway, since the underlying
> problem is intractable there will always be ways for the access
> violation to occur).
>

Good suggestion. There doesn't seem to be any other way to handle this
situation.

I had hoped someone else may had seen this problem and figured out a
way around it.
0
Joe
2/26/2010 12:05:47 AM
Reply:

Similar Artilces:

Limit User Access to certain Vendors
Is there a way to do this that anyone knows of while still allowing access to the rest of the vendors? Eric, I can't see how you would be able to do this without a customization. -- Victoria Yudin Dynamics GP MVP Flexible Solutions, Inc. "Eric Huebschman" <eric@thccorp.com> wrote in message news:38762F86-EE70-446A-8DA0-BAAB1C72CEE8@microsoft.com... > Is there a way to do this that anyone knows of while still allowing access > to the rest of the vendors? On Sep 10, 4:00 pm, "Victoria [MVP]" <victo...@flex-solutions.com> wrote: > Eric, &...

Memo Field From Access To SQL2000
Hi I have an database that is originally in Access97 I converted into Access2000 then used the upsizing wizard to convert to SQL2000. I am now attempting to update the data using Queries however several of the table crash because the memo field data is too larger to fit the field on SQL and as a result the tables don't get updated... Suggestions ? Meir Make destination field in SQL a 'text' field. "Meir Rotfleisch" <meir@mrrcomputers.cc> wrote in message news:OfBjASQ2DHA.2636@TK2MSFTNGP09.phx.gbl... > Hi > > I have an database that is originally in...

Printer set changes when accessing GP from Terminal services
Hi, We are using GP8. My colleague had issues when she tries to print invoices from a GP client installation using terminal services. I help her to change the printer to a physical printer. But it changed back to a different one such as image writer. How the printer setting works for terminal services in GP? Gavin ------=_NextPart_0001_3FF3F32D Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi Gavin Are you using Named Printers? Have a look at the follow post for information on how to set up Named Printers. http://blogs.msdn.com/developingfordynamicsgp/archive/20...

Exchange problems after reboot
Hello! I'm having trouble with Exchange 2003 (Ex2003 SP2 running on Windows Server 2003 SP). Every time after reboot Exchange don't start correctly. I have a "8231 MSExchangeAL" and "8247 MSExchangeAL" errors in application log. Also the Exchange Information Store fails during startup and the Exchante MTA Stacks too. After reboot when I log on to server I can start those two services manualy and everything runs fine, so I'm little (or much) confused. I didn't have problems with reboots before. I have checked KB 27529, KB 286356 and few others and ...

Change date from mm-dd-yyyy to MMM-YY in Access
How do I change a field which contains a date in a mm-dd- yyyy format into mmm-yy format. For Example: Ship Month = 03/01/2004 Convert "Ship Month" value to display "Mar-04" Hi Vince, Set the Format property of the field, and/or the control(s) that are displaying it, to "mmm-yy" On Tue, 20 Apr 2004 12:01:52 -0700, "Vince" <anonymous@discussions.microsoft.com> wrote: >How do I change a field which contains a date in a mm-dd- >yyyy format into mmm-yy format. > For Example: Ship Month = 03/01/2004 > Convert "Ship Month&qu...

Why I cannot stop Messenger from starting with Windows?
Hi, I have removed tick from "Run Windows Messenger" when Windows starts" option in Prefererences tab. Despite that, each time when I start Windows Messenger comes with it. I checked Run regkey and Messenger is not there. How to remove it? Claire See http://kellys-korner-xp.com/xp_messenger.htm. For Messenger/Outlook Express tweaks, see http://kellys-korner-xp.com/xp_oe.htm. Claire wrote: > Hi, > I have removed tick from "Run Windows Messenger" when Windows starts" > option > in Prefererences tab. > Despite that, each time ...

Printer problem when OPENING reports
Access 2002. Opening a database from another user's machine, and when trying to open up a report, a dlg comes up saying that the printer doesn't exist. The printer it lists, is the one that I was hooked up to on my machine when I last printed the report. The person has his own printer, why wouldn't it just print to that printer. I don't have any code or settings that I know of that have made the report do that. That seems like me sending a word doc, and when you open it up, it says MY printer is not available. Of course not, you'd be printing it on YOUR printer....

PC Charge Problem
We have been having a problem with double charging in some instances. We swipe the card and the PC Charge processing screen gets hung up waiting. Sometimes it cancels itself, sometimes it takes a while and we need to cancel it. We then reswipe and it goes through. What ends up happening is that sometimes the first swipe ends up getting charged to the customers account, but does not get registered as a sale on RMS (the second swipe does). Then, once the customer gets their bill and notices the double charge, I need to refund the card, and this gets relected in my sales on RMS. Has ...

converting sub-reports from Access 97 to XP
I converted a 97 database to XP (without going through 2000) and opened a report containing four subreports. The subreports seem to have scroll bar arrows and nothing else visible. I could not click on the subreports through the main report to open them no matter how hard I tried. When I attempted to open the same subreports through the query design window I was told that I could not open the report again since it was already open. I was told I would have to click on "view - subreport through new window." I returned to the main report with the scroll bar arrows and tri...

Excel Function to Access
I would like this excel function =IF(A4=A5,C5-C4,C5) to be utilized a a function in a query in MS Access where the fields that supposed t be in column A are the primary key fields and the next fields whic are in column C, are to be calculated in.The answers to this functio are to go into a new field.....Any help please? : Primary key, by definition, means no duplicates. How would A4 ever equal A5? -- George Nicholson Remove 'Junk' from return address. "CJT" <chico_2186@yahoo-dot-com.no-spam.invalid> wrote in message news:Wa-dnQuiOcaYskDfRVn_vQ@giganews.com... &g...

Matrix Problem
I was trying to match a matrix division, that was written in another code. Matrix A = 1 1 1 1 0 0 0 0 1000 100 10 1 0 0 0 0 0 0 0 0 1000 100 10 1 0 0 0 0 4096 256 16 1 3 2 1 0 0 0 0 0 300 20 1 0 -300 -20 -1 0 0 0 0 0 768 32 1 0 60 2 0 0 -60 -2 0 0 Matrix B = 0.11413125 0.30555 0.30555 0.425 0.0085625 0 0.019908333 0 Matrix C = -0.000135571 0.003038657 0.002891898 0.108336265 8.5706E-05 -0.003599653 0.069275 -0.112940741 The calculation that I am looking at has Matrix B / Matrix A = Matrix C I was trying to use a function in excel to match matrix C, but I have been unable to do this...

Free MS Excel/Access Video Tutorials and Articles
Hey All, There are a whole bunch of free articles and video tutorials at http://www.davidbase.com. There's no cost to sign up and there are lots of articles and videos to check out. Some of the topics are Access VBA, Excel, Database Design, Reporting, Union Queries and more. Some recent articles: Access Parameter Queries Union Queries Excel VBA Random Numbers Relationships and Joins � and plenty more. Sign up (it's free) right on the home page and see if it suits you. Thanks, AppTrix Staff http://www.davidbase.com ...

Exchange2K problem
Hi, I try in a new threat: I have two different lan/wan�s (and two different domaine�s). Domaine1 cannot recieve mail from Domaine2 - there is no problem the other way. Domaine1 can send mails to Domaine2 but Domaine1 cannot recieve any answers from Domaine2. There is also the same problem from two other domains: Domaine1 cannot recive mails from these two. If there more Domains with problems - I dont know. BUT: Domaine1 can recieve mails from everybody else with no problems. I cannot telnet from Domaine2 to Domaine1 port 25 - no connection can be obtained. No problem to telnet from Domai...

Send/Receive problems #3
When using MS outlook for my mail I'm unable to send/receive, as soon as I hit the 'send/receive' tab I get a message in the bottom bar saying 'Mail Delivery complete' with the animated envelopes. If I am sending an e-mail, it goes straight to the outbox, and stays there. I have checked all my settings, and have used 'detect and repair' but this has not helped. Please can anyone help? Thanks The majority of the time that this error occurs is when the mail server settings are correct but it is not recognizing your user name or password. The second and m...

Problem w/MathType and KaleidaGraph embedded objects
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I am having trouble with embedded objects Word 2008 from either of the above programs. Note that I do not have problems with embedded objects created with Office applications such as Excel. I'm not sure about other applications. Here is what happens: If I open a Word Document created with either Word 2003 or Word 2007 on windows that contains an embedded MathType equation or Kaleidagraph graph, when I double click to open it with Word 2008 I get an error that says "Word is unable to locate the server application...

Weird problem -- formulas get lost but their values stay in place
I have a client who uses Excel files that link out to other excel files. The formulas in the "main" file calculate from data in the linked files. So, the formula is in the main file. When they close the main file and re-open it, the formulas are gone, but the last calculated value remains. Does anyone have an idea why this would happen? Thanks, Bill One way might be because a "Before Save" or "Before Close" Macro is doing a Copy > Paste special > Values........ Vaya con Dios, Chuck, CABGx3 "Bill" <bdotson@gmail.com> wrote in message...

Can Windows XP 64 bit be upgraded to Windows Vista 64 bit?
Would I need to reinstall applications? Thanks Partha mcp111 wrote: > Would I need to reinstall applications? Now is a great time to point you to one of the easiest ways to find information on problems you may be having and solutions others have found: Search using Google! http://www.google.com/ (How-to: http://www.google.com/intl/en/help/basics.html ) Your answer: http://www.microsoft.com/windows/windows-vista/get/upgrade-your-pc-options.aspx "If your computer is running Windows 2000 Professional or Windows XP Professional x64, you are eligible for an u...

cannot send email messages from Window Mail
I have email on mail2web.com and I use it from windowsmail so my problem that I can recive email messages but Icannot send Do you get an error message when you try to send? If so,=20 right-click on your error message, copy, then paste it into a reply = here. We can't do much troubleshooting without the complete error message.=20 --=20 Gary VanderMolen, Microsoft MVP (Mail) http://mvp.support.microsoft.com/default.aspx/profile/vandermolen "Hassan" <Hassan @discussions.microsoft.com> wrote in message = news:DA2310DC-3838-43A4-9701-36C4F01F6391@microsoft.com...

Sending Mail from Windows Explorer Q
When you send a mail via Windows Explorer i.e send to mail recipient, how can you do that without the message on the Subject line reading "e- mailing: file that is attached" and also the message that appears within the message body? I always manually delete, but is it possible not to have these messages displayed in the first place? I'm using Outlook 2003 Sean <seanryanie@yahoo.co.uk> wrote: >When you send a mail via Windows Explorer i.e send to mail recipient, >how can you do that without the message on the Subject line reading "e- >mailing: file that is a...

Re: New Build Of Windows Live Mail 2010
This is a multi-part message in MIME format. ------=_NextPart_000_0035_01CB4284.A4A23040 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable In the new beta =E2=80=93 not this version. "Nancy Jackman" <nanwjackman@beaufort.com> wrote in message news:... The problem of WLM=E2=80=99s =E2=80=9Cstepping on itself=E2=80=9D when = compacting and freeing up empty space seems to have been fixed as well. Nancy ------=_NextPart_000_0035_01CB4284.A4A23040 Content-Type: text/html; charset="UTF-8" Content-Transfer-...

oulook calendar problems
When I schedule meetings using oulook 2002 for eg at 10am the receipients are getting invitations for incorrect hours. This could be 11am instead 10 am. The computer time and the time zones are correct. Can someone please help? Daylight Savings Time match in Outlook and Control Panel? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, babu datt asked: | When I schedu...

XML serialization problem #2
Hi all, I'm a .NET beginner and I've got a problem on a program where I try to do an XML serialization. I get the following error : "An unmanaged exception of type 'System.IO.FileNotFoundException' occured in mscorlib.dll Additonal information : the file or asssembly named n9gu4-bo.dll or one of its dependencies cannot be found" Here is the code : (I've uploaded the complete project at this url http://netorld.free.fr/Interface2.zip) public class Form1 : System.Windows.Forms.Form { .... .... public Form1() { InitializeComponent(); try { TextReader reade...

excel find problems
I have a database in excel with 4 sheets. When I want to conduct a search, it only searches the active sheet. Therefore I have to select each sepearte sheet and carry out 4 individual searches. Is there any way to search all sheets at once? If there is not, I am aware I can create a user form and use the approproate syntax to conduct my required search. However this will take me a long time. If there is an easier apprach then please let me know. Regards camron What version of excel? How are you searching? In later versions of Excel, you can select multiple sheets and have Edit|Fin...

Access 2.0 to 2000 or XP
Has anyone tried to convert an Access 2.0 database to a 2000 or XP database. I tried it and I also modified all of the code that seemed to be incompatible, it works, but it still acts like there are some bugs. When clicking on the icon it will open, but after closing once or twice that same icon will start showing the properties instead of launching the program or highlight other icons around it and open other files all at once. I'm running windows 2000 pro and the database I need to convert is still being used daily. I've tried importing the tables and reports, converting, ...

Outlook on windows 7
How to set up recurring appointments on the toolbar - windows 7 "sdevli" <sdevli@discussions.microsoft.com> wrote in message news:FB723333-AFED-4ADA-8666-7F7CCABC8739@microsoft.com... > How to set up recurring appointments on the toolbar - windows 7 Don't think you can. You mean in gadgets? You'll need to look for a gadget that displays appointments (or recurring appointments). There is an upcoming appointments gadget in the online gadget gallery. Note that using a gadget can force outlook open at boot and keep Outlook open if you try to close i...