我想存储在Windows服务器上的一个单独的硬盘介质。是否有可能使通过HTTP提供这些文件? [英] I want to store media on a separate harddrive on the windows server. Is it possible to make those files available via http?

查看:87
本文介绍了我想存储在Windows服务器上的一个单独的硬盘介质。是否有可能使通过HTTP提供这些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的一个客户,他的应用程序允许用户上传所有类型的文件。目前,我们把它们存储在一个文件夹名为C:/ .. /上传这是放在httpdocs根文件夹

For one of my clients, his application allows users to upload all types of documents. Currently we store them in a folder called C:/.. /Uploads which is in the httpdocs root folder.

是否有可能将这些存储上传一个单独的硬盘驱动器(D:/),并以某种方式链接到我的.NET应用程序中的驱动器/文件夹,这样我可以从浏览器访问/Uplo​​ads/somefile.gif无需编写特殊code处理HTTP请求,抓住了应用程序中的文件,并返回它。

Is it possible to store these uploads on a separate hard disk drive (D:/) and somehow link that drive/folder within my .NET application so that i can access /Uploads/somefile.gif from a browser without needing to write special code that handles the http request, grabs the file within the application and returns it.

我想preFER使用的东西窗口服务器内的原生如果有什么可以代替写我自己的解决方案和腹胀的应用程序。

I would prefer to using something native within windows server if anything is available instead of writing my own solution and bloating the application.

我是一个.NET开发人员,但我还不熟练使用Windows服务器,所以我无法找到网上类似的问题/解决方案,因为我不知道什么关键词来搜索。

I am a .NET developer but am not skilled with windows server so I am having trouble finding similar problems/solutions online because I don't know what keywords to search for.

推荐答案

是的..你可以很容易地通过简单地设置一个新的驱动器路径做到这一点。究竟如何你做这取决于你现在怎么codeD的应用和链接的文件很多。没有与指定新位置没有问题。你可以使code通过无限$ P $灵活ptending D盘是另一台服务器..在网络上下面的例子就是赌我见过。

yes.. you can easily do this by simply setting a new drive path. How exactly you do this depends alot on how you coded the application and link to the files now. There is no issue with specifying the new location. You could make the code infinitely flexible by pretending the D drive is another server.. the following example on the web is the bet Ive seen.

http://www.$c$cproject.com/Articles/19830/How-to-Access-Network-Files-using-asp-net

不过,最简单的方法

连接字符串

到OLE数据源的连接是通过OleDbConnection对象管理。这是的System.Data.OleDb,这是OLE DB的.NET Framework数据提供程序的一部分。建立连接的最简单的方法是使用它接受一个连接字符串的构造。下面是使用CSV文件的格式为:

The connection to the OLE data source is managed by the OleDbConnection object. It's part of the System.Data.OleDb Namespace, which is the .NET Framework Data Provider for OLE DB. The easiest way to establish a connection is to use the constructor which accepts a connection string. Here is the format to use for CSV files:

 Dim objConnection As OleDbConnection = New   OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
                                     & "Data Source='<File Directory>';" _
                                     & "Extended Properties='text;HDR=Yes;FMT=Delimited';")

注意,数据源指向包含文本文件的文件夹。它允许一个以上的文件的存取。把它看成是数据文件的存储库,很像一个数据库表和视图的存储库。因此,每个文件重新presents一个表或视图。

Notice that the Data Source points to the folder which contains the text file. That allows for the accessing of more than one file. Think of it as a repository of data files, much like a database is a repository of tables and views. Hence, each file represents one table or view.

到ODBC .NET数据源的连接是由Microsoft.Data.Odbc命名空间的OdbcConnection对象的管理。它还提供了接受一个连接字符串的构造:

The connection to the ODBC .NET data source is managed by the OdbcConnection object of the Microsoft.Data.Odbc Namespace. It also provides a constructor which accepts a connection string:

Dim objConnection As OdbcConnection = New OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};" _
                                    & "Dbq='<File Directory>';" _
                                    & "Extensions=asc,csv,tab,txt;")

的文本ODBC驱动可并入旧的编码技术,如VBScript或传统的ASP,因为它predates净。下面的例子演示了如何使用分级ASP ADO连接的建立:

The Text ODBC Driver can be incorporated into older coding technologies such as VBScript or classic ASP since it predates .Net. The following example demonstrates the creation of an ADO connection using classing ASP:

Dim Conn
Set Conn = CreateObject("ADODB.Connection")

Conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" _
        & "Dbq='<File Directory>';" _
        & "Extensions=asc,csv,tab,txt;")

这篇关于我想存储在Windows服务器上的一个单独的硬盘介质。是否有可能使通过HTTP提供这些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆