| | |
file upload
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2007
Posts: 189
Reputation:
Solved Threads: 16
In my code I want to upload a file to my project(named Musiker), under the folder music. Here is what I did so far, it's not working.
'to get the path where to upload it, I did the following
Dim strpath As String = Application.StartupPath
Dim num As Integer = strpath.IndexOf("Musiker")
strpath = strpath.Remove(num + 7) & "\music"
'now I want to upload a file
Dim clsRequest As System.Net.FileWebRequest = (System.Net.WebRequest.Create(strpath))
clsRequest.Method = System.Net.WebRequestMethods.File.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes("pathofFile")
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
It gives me an error, access not allowed or something like that.
'to get the path where to upload it, I did the following
Dim strpath As String = Application.StartupPath
Dim num As Integer = strpath.IndexOf("Musiker")
strpath = strpath.Remove(num + 7) & "\music"
'now I want to upload a file
Dim clsRequest As System.Net.FileWebRequest = (System.Net.WebRequest.Create(strpath))
clsRequest.Method = System.Net.WebRequestMethods.File.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes("pathofFile")
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
It gives me an error, access not allowed or something like that.
plusplus & martonx.
You are requested to use BB code tags.
You are requested to use BB code tags.
VB.NET Syntax (Toggle Plain Text)
My.Computer.Network.UploadFile("source file path","destination address")
Last edited by adatapost; Jul 1st, 2009 at 4:14 am.
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jul 2007
Posts: 189
Reputation:
Solved Threads: 16
Let me change my question. Since I am new to vb.net, but worked in asp.net, I thought I have to upload the file. But really what I have to do, is save it to my project. So what I really needed was
File.Copy(sourceFile, destinationFile)
My question is, when using a path for the destination file, where would I put it, so that it should be part of my project?
File.Copy(sourceFile, destinationFile)
My question is, when using a path for the destination file, where would I put it, so that it should be part of my project?
•
•
Join Date: Jul 2007
Posts: 189
Reputation:
Solved Threads: 16
Sorry, here with code tags
Let me change my question. Since I am new to vb.net, but worked in asp.net, I thought I have to upload the file. But really what I have to do, is save it to my project. So what I really needed was
My question is, when using a path for the destination file, where would I put it, so that it should be part of my project?
Let me change my question. Since I am new to vb.net, but worked in asp.net, I thought I have to upload the file. But really what I have to do, is save it to my project. So what I really needed was
VB.NET Syntax (Toggle Plain Text)
File.Copy(sourceFile, destinationFile)
My question is, when using a path for the destination file, where would I put it, so that it should be part of my project?
![]() |
Similar Threads
- File Upload Help (PHP)
- File upload problem (PHP)
- Need file upload code for word Doc (HTML and CSS)
Other Threads in the VB.NET Forum
- Previous Thread: Database Connectivity
- Next Thread: how to get the HTML source code of the page embeded with AJAX
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add advanced application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity pan peertopeervideostreaming picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf xml






