Welcome Guest Search | Active Topics | Sign In | Register

Copying a file from the local file system to a web folder Options
Peter
Posted: Tuesday, March 12, 2013 7:37:51 AM
Rank: Member
Groups: Member

Joined: 8/30/2011
Posts: 17
I apologise in advance for what must seem like such a dumb question. I have an ASP.NET 1.1 application that relies on a spreadsheet being imported into a SQL Server table. I've written a DTS package to perform the import and that works as expected. The spreadsheet is sent via an email because the owner does not have (and cannot be given) access to the web application. The spreadsheet attachment is saved either to the user's local hard disk or to a network share which I've configured through some keys in web.config.

I simply want to copy this file through my web application from the local (or network) drive to the web server. For example, the file might be in a location like this:

C:\Equipment\Spreadsheets\abc.xls (this is on a local machine)

and I want to copy it to:

C:\inetpub\wwwroot\TSP_Test\Equipment\ (this is on the web server machine)

I'm using the AJAXUploader and can browse to the file but when I attempt to save it, the file has zero bytes, although the file name is correct.

Here's the code I'm using and I'm obviously missing something very simple:

Code: Visual Basic.NET
Dim fileStream As FileStream
        Dim streamWriter As StreamWriter
        Dim strExportFile As String = Server.MapPath(Me.ID) + "/" + ConfigurationSettings.AppSettings("ProtegeSpreadsheetLocation") + FileName
        fileStream = New FileStream(strExportFile, FileMode.Create, FileAccess.Write)
        streamWriter = New StreamWriter(fileStream)
        streamWriter.Close()
        fileStream.Close()


The filename in the AJAX uploader is correct as shown in the image below

eo_support
Posted: Tuesday, March 12, 2013 8:48:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Our tech support won't review or troubleshoot your code. So we will not be able to tell you what's wrong in your code that tries to copy the file. If you have any question directly related to the AJAXUploader, please feel free to ask and we will be happy to help you on that.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.