UnauthorizedAccessException

Jun 30, 2015 at 3:31 PM
Edited Jun 30, 2015 at 3:31 PM
In our TFS build system, I've added a custom step for deleting the old source code before starting a new build, which needs to be custom because we're using npm which creates folders past the long path limit. I've successfully used AlphaFS for this, but it was taking a long time, so it looked like QuickIO would fit our needs better. However, when switching to use QuickIO, I'm getting an UnauthorizedAccessException. I don't get a similar exception from AlphaFS or from plain System.IO usage, so it seems as though there's something different that QuickIO is doing that's triggering the exception.

My code is a very straightforward recursive delete, passing in a string for the path:
SchwabenCode.QuickIO.QuickIODirectory.Delete(directory, true)
Here's the full stack trace:
System.UnauthorizedAccessException: Access to 'C:\Builds\1\ACR\CI (ACR)\src\.eslintrc' denied. ---> 
System.ComponentModel.Win32Exception: Access is denied --- End of inner exception stack trace --- 
at SchwabenCode.QuickIO.Internal.InternalQuickIOCommon.NativeExceptionMapping(String path, Int32 errorCode) at SchwabenCode.QuickIO.Internal.InternalQuickIO.DeleteFile(String path) at SchwabenCode.QuickIO.Internal.InternalQuickIO.DeleteDirectory(QuickIODirectoryInfo directoryInfo, Boolean recursive) 
at SchwabenCode.QuickIO.Internal.InternalQuickIO.DeleteDirectory(QuickIOPathInfo pathInfo, Boolean recursive) 
at Engage.BuildProcess.Activities.DeleteDirectory.AttemptDelete(CodeActivityContext context, String directory, Int32 tries)
Any thoughts on anything I could do differently, or what might be causing the error?

Thanks!
Coordinator
Jun 30, 2015 at 5:05 PM
Hi. Can you give me all attribute information that are assigned to the file?
C:\Builds\1\ACR\CI (ACR)\src.eslintrc

Thanks
Jun 30, 2015 at 5:09 PM
It's marked as "ReadOnly, Archive"

Thanks!
Coordinator
Jul 1, 2015 at 12:08 PM
There was a bug a few versions ago, that I've missed to remove the attributes.
Which version are u using? The newest?

Let me know this and I'll check that again. Maybe there is something that I've missed in my tests.
Jul 1, 2015 at 2:59 PM
I'm on 2.6.2.0 (from NuGet)

Thanks!
Coordinator
Jul 3, 2015 at 7:48 PM
Thank u. I will check that this weekend.
Coordinator
Jul 3, 2015 at 11:51 PM
This is my test to validate delete with file attributes.
      [TestMethod( )]
        public void File_Readonly_Delete_Test( )
        {
            using ( var prov = new RandomTestFileProvider( ) )
            {
                var file = prov.CreateRandomTestFile( );

                Assert.IsTrue( File.Exists( file ), "Created test file does not exists (SystemIO)." );

                File.SetAttributes( file, FileAttributes.ReadOnly );

                var attributes = File.GetAttributes( file );
                Assert.IsTrue( attributes.HasFlag( FileAttributes.ReadOnly ) );

                QuickIOFile.Delete( file );

                Assert.IsFalse( File.Exists( file ), "File still exists after delete." );
            }
        }
QuickIOFile.Delete( file ); removes all attributes (sets to "Normal").

Please check https://quickio.codeplex.com/releases/view/616085
Jul 6, 2015 at 4:04 PM
Thanks, the beta release seems to have fixed the issue. I appreciate you looking into it for me.
Coordinator
Jul 10, 2015 at 1:22 PM
Edited Jul 10, 2015 at 1:22 PM
Ok thank you. I will the new version in August. Currently a lot of project pressure :-/