Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphaleonis.Win32.Network.Host.GetShareInfo doesn't work since 2.1.0 #289

Closed
Schoolmonkey opened this issue Nov 11, 2016 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@Schoolmonkey
Copy link

While the mehtod workes great in 2.0.1, after Upgrade using just 2 params
Host.GetShareInfo Method (String, Boolean),

in 2.1.0 and newer versions I got an Invalid Share Error

System.Net.NetworkInformation.NetworkInformationException (0x80004005): Diese fr
eigegebene Ressource existiert nicht
bei Alphaleonis.Win32.Network.Host.GetShareInfoCore(ShareInfoLevel shareLevel
, String host, String share, Boolean continueOnException) in D:\Coding\Projects
GitHub\AlphaFS\AlphaFS\Network\Host Class\ServerMessageBlock.cs:Zeile 383.
bei Alphaleonis.Win32.Network.Host.GetShareInfo(String uncPath, Boolean conti
nueOnException) in D:\Coding\Projects\GitHub\AlphaFS\AlphaFS\Network\Host Class
ServerMessageBlock.cs:Zeile 172.

I hope you can help me.
Greetings

@Schoolmonkey Schoolmonkey changed the title Alphaleonis.Win32.Network.Host.GetShareInfo doesn't work sinde 2.1.0 Alphaleonis.Win32.Network.Host.GetShareInfo doesn't work since 2.1.0 Nov 11, 2016
@Yomodo
Copy link
Collaborator

Yomodo commented Nov 12, 2016

You are 100% sure the share exists?

@Schoolmonkey
Copy link
Author

Schoolmonkey commented Nov 14, 2016

@Yomodo
I think I am. I've tested it with 3 servers using shares, the explorer can find without any problems.
Does it work in your environment? When I use the "Get-WmiObject Win32_share" command in the powershell the share is found as well. (Tested with a Windows Server 2012 R2)

The shares have been in format "\server\name".

@v2kiran
Copy link

v2kiran commented Dec 12, 2016

yup i can confirm that...
@Schoolmonkey - as a workaround you could use this method which worked for me.

GetShareInfo(
string host,
string share,
bool continueOnException
)

@damiarnold
Copy link

It would appear that in the GetShareInfo() function overloads with the single string for uncPath, that the uncPath is first processed as:

var unc = GetHostShareFromPath(uncPath);

This function appears to return the host portion (unc[0]) correctly, but the share path portion (unc[1]) returns with a leading backslash. At this point, it would appear that the leading backslash is correct in the return from GetHostShareFromPath() via the code comments / documentation, however, in looking at older versions of this function it looks like it did not return a leading backslash? This may have changed for Fix #132 with commit 2d5a25b ?

I can reproduce this issue and subsequent "fix" fairly easily in something like LinqPad, for example:

Broken call (similar to what is in the code today):
var hostShare = Host.GetHostShareFromPath(path);
Host.GetShareInfo(hostShare[0], hostShare[1], false);

Working call:
var hostShare = Host.GetHostShareFromPath(path);
Host.GetShareInfo(hostShare[0], hostShare?[1].TrimStart("\".ToCharArray()), false);

Anyway, without knowing where to make the appropriate change, and being new to GitHub pull requests, I'm posting a possible solution here.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants