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 5690
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |