mike55 Posted August 15, 2005 Posted August 15, 2005 Hi Am in the process of trying to upload and download files from a web server. I have, at this point, the upload function operational: If Not (filMyFile.PostedFile Is Nothing) Then Dim myFile As HttpPostedFile myFile = filMyFile.PostedFile 'Get the size of the uploaded file. Dim nFileLen As Int16 nFileLen = Convert.ToInt16(myFile.ContentLength) 'Verify that the file size is greater than 0 If nFileLen > 0 Then 'Allocate a buffer for reading of the file. Dim myData((nFileLen)) As Byte 'Read uploaded file from the stream. myFile.InputStream.Read(myData, 0, (nFileLen)) 'Create a name for the file to store. Dim strFilename As String = Path.GetFileName(myFile.FileName) 'Verify that the file is in the correct format, i.e. ".csv" or ".txt" If verifyFileType(strFilename) = False Then Me.lblInfo.Text = "File Type cannot be accepted." Exit Sub End If 'Write the file to the new location. WriteToFile("C:\Suretxtlog\" + strFilename, myData) 'Export the file to the Database table. WriteToDB(strFilename) endif Downloading on the otherhand, well thats a whole different ballgame, any suggestions on how to get around this problem? Have been searching the Internet, but can see nothing for downloading the file. The file that I am trying to download is a ".CSV" file. Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted August 15, 2005 Administrators Posted August 15, 2005 You could just return the file contents as a byte array - the receiving application would then need to be responsible for saving it to disk. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted August 16, 2005 Author Posted August 16, 2005 Should have stated that I am working with a web project, will take a look at this byte array. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.