I have the following code (copied from the web somewhere) which I am using
to upload some files:
Dim Filename As String = Dir(OutBox)
Do
Dim request As FtpWebRequest =
WebRequest.Create("ftp://<serverIP>/inbox/" & Filename)
request.Method = WebRequestMethods.Ftp.UploadFile
request.UseBinary = True
request.Credentials = New NetworkCredential("username",
"password")
Dim sourcestream As New StreamReader(OutBox & Filename)
Dim Filecontents As Byte()
Filecontents =
Encoding.UTF8.GetBytes(sourcestream.ReadToEnd())
sourcestream.Close()
request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream()
requestStream.Write(Filecontents, 0, Filecontents.Length)
requestStream.Close()
Dim response = request.GetResponse()
response.Close()
File.Delete(OutBox & Filename)
Filename = Dir()
If Filename = "" Then Exit Do
Loop
I am copying jpg files so need a binary transfer. My problem is with the
encoding line. I don't want any encoding - I just want to copy the file as
it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry 3 5686
Hi jerry,
if you do not need to take control of the stream
why do not make life easier with (vb2005)
My.Computer.Network.UploadFile(sourcefile, TargetServerAndFileName,
UserId, Password, true, 1000)
-tom
Jerry Spence1 ha scritto:
I have the following code (copied from the web somewhere) which I am using
to upload some files:
Dim Filename As String = Dir(OutBox)
Do
Dim request As FtpWebRequest =
WebRequest.Create("ftp://<serverIP>/inbox/" & Filename)
request.Method = WebRequestMethods.Ftp.UploadFile
request.UseBinary = True
request.Credentials = New NetworkCredential("username",
"password")
Dim sourcestream As New StreamReader(OutBox & Filename)
Dim Filecontents As Byte()
Filecontents =
Encoding.UTF8.GetBytes(sourcestream.ReadToEnd())
sourcestream.Close()
request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream()
requestStream.Write(Filecontents, 0, Filecontents.Length)
requestStream.Close()
Dim response = request.GetResponse()
response.Close()
File.Delete(OutBox & Filename)
Filename = Dir()
If Filename = "" Then Exit Do
Loop
I am copying jpg files so need a binary transfer. My problem is with the
encoding line. I don't want any encoding - I just want to copy the file as
it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry
Thanks a lot Tom - I was sort of aware of that command in VB2005, but I
hadn't appreciated its power.
As a tip for others who come across this thread, the destination server must
be ftp://<ipaddressor http://<ipaddressto get it to work.
-Jerry
<to**************@uniroma1.itwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi jerry,
if you do not need to take control of the stream
why do not make life easier with (vb2005)
My.Computer.Network.UploadFile(sourcefile, TargetServerAndFileName,
UserId, Password, true, 1000)
-tom
Jerry Spence1 ha scritto:
>I have the following code (copied from the web somewhere) which I am using to upload some files:
Dim Filename As String = Dir(OutBox) Do Dim request As FtpWebRequest = WebRequest.Create("ftp://<serverIP>/inbox/" & Filename) request.Method = WebRequestMethods.Ftp.UploadFile request.UseBinary = True
request.Credentials = New NetworkCredential("username", "password")
Dim sourcestream As New StreamReader(OutBox & Filename) Dim Filecontents As Byte() Filecontents = Encoding.UTF8.GetBytes(sourcestream.ReadToEnd() ) sourcestream.Close() request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream() requestStream.Write(Filecontents, 0, Filecontents.Length) requestStream.Close() Dim response = request.GetResponse() response.Close() File.Delete(OutBox & Filename) Filename = Dir() If Filename = "" Then Exit Do Loop
I am copying jpg files so need a binary transfer. My problem is with the encoding line. I don't want any encoding - I just want to copy the file as it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry
Another tip is that I couldn't get ftp://123.456.789.012 to work. I don't
know why, but I found that if I put a reference in my HOSTS table to a name
(myserver) and then ftp://myserver worked just fine
-Jerry
_______________________________________________
"Jerry Spence1" <je**********@somewhere.comwrote in message
news:44***********************@ptn-nntp-reader03.plus.net...
Thanks a lot Tom - I was sort of aware of that command in VB2005, but I
hadn't appreciated its power.
As a tip for others who come across this thread, the destination server
must be ftp://<ipaddressor http://<ipaddressto get it to work.
-Jerry
<to**************@uniroma1.itwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>Hi jerry,
if you do not need to take control of the stream why do not make life easier with (vb2005)
My.Computer.Network.UploadFile(sourcefile, TargetServerAndFileName, UserId, Password, true, 1000)
-tom
Jerry Spence1 ha scritto:
>>I have the following code (copied from the web somewhere) which I am using to upload some files:
Dim Filename As String = Dir(OutBox) Do Dim request As FtpWebRequest = WebRequest.Create("ftp://<serverIP>/inbox/" & Filename) request.Method = WebRequestMethods.Ftp.UploadFile request.UseBinary = True
request.Credentials = New NetworkCredential("username", "password")
Dim sourcestream As New StreamReader(OutBox & Filename) Dim Filecontents As Byte() Filecontents = Encoding.UTF8.GetBytes(sourcestream.ReadToEnd( )) sourcestream.Close() request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream() requestStream.Write(Filecontents, 0, Filecontents.Length) requestStream.Close() Dim response = request.GetResponse() response.Close() File.Delete(OutBox & Filename) Filename = Dir() If Filename = "" Then Exit Do Loop
I am copying jpg files so need a binary transfer. My problem is with the encoding line. I don't want any encoding - I just want to copy the file as it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Mosser |
last post by:
I'm looking for an applet that allows for multiple file uploads. I found
jupload and am considering using that, but I might have a couple issues. I
need to build a web app for a print shop, that...
|
by: Chris |
last post by:
I'm trying to automate the process of uploading files from a client to
a webserver. I know that this can't be done by setting the value of
the file field in an html form.
So far, the plan is to...
|
by: Paul |
last post by:
Hi there,
When adding a "File Field" HTML control to an aspx page to facilitate file
uploading, the following occurs:
1. You select a file that is larger than the allowed size limit.
2. Once...
|
by: Jen |
last post by:
I'm using Microsoft's own VB.NET FTP Example:
http://support.microsoft.com/default.aspx?scid=kb;en-us;832679
I can get the program to create directories, change directories, etc.,
but I can't...
|
by: David Lozzi |
last post by:
Howdy,
I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!
Now I am making a public function that will take the...
|
by: Mike Kelly |
last post by:
Hi. I've built a page using standard ASP.NET 2.0 features and when I upload a
large file (>20MB) to our intranet server, I get a paltry 100KB/s on our
100Mb/s LAN. Simply copying the file, I get...
|
by: joshbeall |
last post by:
Hi All,
If I drop a form onto my page that allows file uploads, I know well
enough how to handle the file upload in the server side via PHP.
However, I have a question: when my browser...
|
by: Marko Vuksanovic |
last post by:
I used the following code for implementing a file upload progress indicator, using UpdateProgress Panel, though I have a problem that FileUpload.Has File always returns false. Any suggestions what...
|
by: Jerry Spence1 |
last post by:
I have the following code (copied from the web somewhere) which I am using
to upload some files:
Dim Filename As String = Dir(OutBox)
Do
Dim request As FtpWebRequest =...
|
by: Gert Conradie |
last post by:
The following code can uplaod text files. When i upload a binary file
it fail.
I might be:
1) using the wrong Encoding
2) will have to System.Convert.ToBase64String the content of the
binary...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |