0

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.

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.

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

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.

user692942
  • 16,398
  • 7
  • 76
  • 175
masteroleary
  • 1,014
  • 2
  • 16
  • 33
  • How do you expose file to user? A direct link on http page from location on the server? – T.S. Nov 07 '14 at 16:41
  • Yes. website.com/uploads/somefile.txt – masteroleary Nov 07 '14 at 16:52
  • Look at this: http://stackoverflow.com/questions/1369147/linking-a-unc-network-drive-on-an-html-page sound as all you need is to create another virtual directory and point it to a mapped drive. Then point your page to that VD. Your VD should probably be sub-dir of your web site – T.S. Nov 07 '14 at 16:53

1 Answers1

0

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.codeproject.com/Articles/19830/How-to-Access-Network-Files-using-asp-net

The most simple approach however

The Connection String

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';")

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.

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;")

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;")
T.S.
  • 18,195
  • 11
  • 58
  • 78