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

Read/Write on a network folder #30

Open
enrichz opened this issue May 21, 2018 · 6 comments
Open

Read/Write on a network folder #30

enrichz opened this issue May 21, 2018 · 6 comments

Comments

@enrichz
Copy link

enrichz commented May 21, 2018

I would like to read and write on a folder placed on a shared storage using the SubFileSystem. Is this possible? I can't seem to find the way, I always get the exception:
A path on Windows must start by /mnt/ followed by the drive letter.
Also, I'd like to be compatible with both Windows and Linux.

This is the code I have:

UPath root = "\\\\myserver\\PublicFolder\\";
var fs = new PhysicalFileSystem();
if (!fs.DirectoryExists(root))
{
	fs.CreateDirectory(root);
}
var subfs = new SubFileSystem(fs, root);

Thanks

@xoofx
Copy link
Owner

xoofx commented Jun 18, 2018

It is indeed not possible.

Also, I'd like to be compatible with both Windows and Linux.

What do you mean? Afaik, Linux doesn't have an equivalent of that right?

@xoofx xoofx added the question label Jun 18, 2018
@guillaume86
Copy link

I would also be interested in this feature, maybe a "/smb/SERVER-> \\SERVER" convention enabled in windows environments could do the job the same way you handle local drives with "/mnt/C -> C:\".

Thank you for this lib, it looks very useful and well written.

@LimpingNinja
Copy link

Just adding a comment - on Linux you would mount an SMB path for perusal or use an smbclient; on Windows you'd do the same with NET USE:

net use s: \\myserver\publicfolder

Then in Zio you would use:

UPath root = "/mnt/s/";

Essentially using the 'net use' is mounting the path as a subsystem and even works on local. @guillaume86 how would you envision this being cross-supported or is this a windows only feature side?

@VaslD
Copy link

VaslD commented Jun 1, 2020

Something like \\MyServer\PublicFolder (unescaped) is an UNC Path. In short, UNC Path is the Windows way to normalize different formats of file paths, e.g. C:\Windows\, \\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.txt, D:Folder1 (yes, there is no / or \) can all be converted to UNC Paths. (But they don't have to be.)

.NET built-in IO accepts UNC Paths and other valid but not portable path formats on Windows. UPath may need additional logic to support conversion between different special path formats.

@guillaume86
Copy link

guillaume86 commented Jun 12, 2020

Maybe a /unc/ root path could handle that on windows platforms?
Just translating itself to \\ when transformed into a native path similarly to what /mnt/ is doing for mounted drives.

@xoofx any remarks/recommendations if someone was to tackle that?

@xoofx
Copy link
Owner

xoofx commented Jun 12, 2020

The integration into PhysicalFileSystem doesn't match. A unc is like an http connection where you have the host and the path inside it.
I would prefer a new UncFileSystem("\\\\myserver\\PublicFolder\\") is introduced even if it requires to move some parts of PhysicalFileSystem to a base class.
Note also that it might require to disable the file watcher API for this one.
I don't have time, nor any personal interest in this feature, but a PR is welcome.

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

No branches or pull requests

5 participants