简体   繁体   English

在C#中访问UNC路径的最佳方法

[英]Best way to access a UNC path in C#

We are building an application that will be storing a lot of images. 我们正在构建一个将存储大量图像的应用程序。 We have a virtualized environment at GoGrid.com and we were hoping to utilize their cloud storage. 我们在GoGrid.com上拥有一个虚拟化环境,我们希望利用其云存储。

Not sure exactly how to word this, but if we (in our code) specify the unc path and creds to place or retrieve an image, that seems terribly inefficient (connect, get image, disconnect) 不确定确切的措辞,但如果(在我们的代码中)指定放置或检索图像的unc路径和凭据,这似乎效率很低(连接,获取图像,断开连接)

If we have a large volume of images or many users performing this at once, it seems like it would bring any normal server to it's knees. 如果我们有大量的图像或有许多用户一次执行此操作,则似乎它将使任何普通服务器都屈服。

So my question is, short of having huge drives that your website is running on, how should we aim to accomplish this? 所以我的问题是,您的网站运行时缺少大量驱动器,我们应该如何实现这一目标? Again, we are opting for the GoGrid cloud starge versus Amazon S3 since everything is under one nice umbrella. 再次,我们选择GoGrid云技术而不是Amazon S3,因为一切都在一个很好的范围内。 The cloud storage is accessible via a UNC path and a specific username/password. 可通过UNC路径和特定的用户名/密码访问云存储。

Thanks! 谢谢!

C# can use unc paths like native paths, using the native operating system file i/o. C#可以使用本机操作系统文件I / O使用unc路径(如本机路径)。 Normally, you don't "connect/retrieve/disconnect", but rather once established the connection to the remote server will be held, as if you mapped a drive. 通常,您不是“连接/检索/断开连接”,而是一旦建立就将保持与远程服务器的连接,就像您映射了驱动器一样。 Just because you don't have a drive letter for it, it doesn't mean there's no connection. 仅仅因为您没有驱动器号,并不意味着没有连接。

Alternatively (and knowing nothing about go grid), you could either just map a drive or use the Offline Files feature in Windows to keep the most frequently accessed files cached locally. 另外(对go grid一无所知),您既可以映射驱动器,也可以使用Windows中的“脱机文件”功能将访问频率最高的文件保存在本地。

If you think you might be changing the file access method over the course of time, then be certain to keep it abstract. 如果您认为您可能会随着时间的流逝而更改文件访问方法,那么一定要使其保持抽象。 Start off with a simple UNC implementation, but you would then be able to change to a web service or REST implementation later. 从一个简单的UNC实施开始,但是以后您可以更改为Web服务或REST实施。

I have not worked with high volume access servers before, but it sounds to me like you are looking for something very lightweight accessing a UNC path. 我以前没有使用过大容量访问服务器,但是听起来像是您正在寻找一种轻量级的访问UNC路径的服务器。 Facebook has an architecture based on a lightweight HTTP implementation and blade servers for load balancing using a single 10TB filesystem, but you don't sound like you're quite there yet. Facebook拥有一个基于轻量级HTTP实现和刀片服务器的架构,可使用单个10TB文件系统进行负载平衡,但听起来还不存在。 If you want to maximize what you get out of the connects, try to pull multiple files in a connect/read/disconnect sequence. 如果要最大程度地利用连接,请尝试按连接/读取/断开连接顺序拉多个文件。 Be warned that this will make your users wait a little while longer, and 20ms slower for google lead to something like a 20% drop in users. 请注意,这会使您的用户等待一会儿更长的时间,而Google的等待时间会慢20毫秒,导致用户数量下降20%。 Aside from that, I don't know of any faster way to do it than to simply access the path. 除此之外,除了简单地访问路径之外,我不知道有什么更快的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM