Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

InvalidOperationException on Directory.EnumerateFileSystemEntries() #441

Closed
CyberSinh opened this issue May 12, 2018 · 17 comments
Closed

InvalidOperationException on Directory.EnumerateFileSystemEntries() #441

CyberSinh opened this issue May 12, 2018 · 17 comments
Assignees
Labels
Milestone

Comments

@CyberSinh
Copy link
Contributor

Hi,

If I run these commands under PowerShell:

$path = "\\Ds216j\sauvegardes\Documents" # it's a shared folder on a Synology NAS
[Alphaleonis.Win32.Filesystem.Directory]::GetFileSystemEntryInfo($path)
[Alphaleonis.Win32.Filesystem.Directory]::EnumerateFileSystemEntries($path)

I get the following output:

1526105805067blob

As you can see, the target folder is well identified as a directory by AlphaFS. However, if I try to enumerate the contents of this folder, I get an error "the target directrory is a file, not a directory".
Does anybody know why?

Thanks.

@Yomodo
Copy link
Collaborator

Yomodo commented May 12, 2018

curious.. how about other unc/local paths?
It think that the problem is not the path itself (\\Ds216j\sauvegardes\Documents), but the
next folder or file that is returned by the enumeration. InvalidOperationException can point
to a cyclic operation.

@fwi98
Copy link

fwi98 commented May 16, 2018

Ok . How can i see the "next folder or file returned" ? NAS logs or PC logs?
Some folder are OK , other not.
Thanks
Regards

@Yomodo
Copy link
Collaborator

Yomodo commented May 16, 2018

Hm.. the only way I can think of is using the VS debugger.

@CyberSinh
Copy link
Contributor Author

Hi Yomodo.
You will find attached the IntelliTrace file sent by the end user affected by this issue.
Hope you will find it useful to diagnoose the issue.
Thanks.

AlphaFS.itrace.zip

@CyberSinh
Copy link
Contributor Author

Hi Yomodo. Was this iTrace file useful to you? Do you need more information?

@Yomodo
Copy link
Collaborator

Yomodo commented May 21, 2018

Hi CyberSinh, thanks for this. Will analyze this in the next days.

@Yomodo
Copy link
Collaborator

Yomodo commented May 23, 2018

Unfortunately, I only have access to VS 2015 Enterprise, loading the .Itrace throws a waring that I'm not able to view all the information.

However, the Exception is thrown here:

throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_PATH_NOT_FOUND, string.Format(CultureInfo.InvariantCulture, Resources.Target_Directory_Is_A_File, regularPath)));

If you can place a breakpoint and run debug again, you should be able to see exactly what data win32FindData and regularPath contain. Hopefully this can tell us more.

@CyberSinh
Copy link
Contributor Author

Hi Yomodo,
You will find below a screenshot of Visual Studio 2017 with the iTrace log file opened:
debug

You can view the win32FindData variable data.

@Yomodo Yomodo self-assigned this May 23, 2018
@Yomodo Yomodo added this to the vNext milestone May 23, 2018
@Yomodo
Copy link
Collaborator

Yomodo commented May 24, 2018

I think the fix is simple; could you change this line:


to: if (null != handle && lastError != Win32Errors.NO_ERROR)

@Yomodo Yomodo changed the title InvalidOperationException on Directory.EnumerateFileSystemEntrie() InvalidOperationException on Directory.EnumerateFileSystemEntries() May 24, 2018
@Yomodo Yomodo closed this as completed in 8cc8a03 May 24, 2018
@Yomodo Yomodo reopened this May 24, 2018
Yomodo added a commit that referenced this issue May 24, 2018
@Yomodo Yomodo closed this as completed in 6d74e04 May 24, 2018
Yomodo added a commit that referenced this issue May 24, 2018
@Yomodo Yomodo reopened this May 24, 2018
@CyberSinh
Copy link
Contributor Author

Thank you very much Yomodo!

@Yomodo
Copy link
Collaborator

Yomodo commented May 24, 2018

It works? Cool!

@CyberSinh
Copy link
Contributor Author

I will propose a modified version of AlphaFS to the user concerned by this issue to check if the patch works. I'll keep you informed.

@CyberSinh
Copy link
Contributor Author

I'm sorry but the user concerned has told me that the patch does not work. The same error always occurs. Here is the new IntelliTrace log:
AlphaFS2.zip

@Yomodo Yomodo reopened this May 25, 2018
Yomodo added a commit that referenced this issue May 25, 2018
-Updated CHANGELOG.md;
@Yomodo
Copy link
Collaborator

Yomodo commented May 31, 2018

I've made a new branch #441 based on the latest master. Could you test again with this?

@CyberSinh
Copy link
Contributor Author

CyberSinh commented Jun 1, 2018

Everything works fine with this new branch. You can merge it. Thank you.

Yomodo added a commit that referenced this issue Jun 1, 2018
@CyberSinh
Copy link
Contributor Author

Any timinig for a new maintenance nuget release?

@Yomodo
Copy link
Collaborator

Yomodo commented Jun 4, 2018

Soon, I'll start preparing.

@Yomodo Yomodo modified the milestones: vNext, Release 2.2 Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants