473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Upload File via FTP using VB.Net and Receiving "Not Logged In" Error??

TC
Hey All,

I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.

Unfortunately, I'm receiving a "Not Logged In" error.

I know that others have seen this as I've seen postings but I haven't seen
any clear resolution.

Does anyone have a code snippet that works?

Can someone please advise?

Thanks,

TC
Jul 29 '08 #1
5 7892
On Jul 29, 3:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey All,

I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.

Unfortunately, I'm receiving a "Not Logged In" error.

I know that others have seen this as I've seen postings but I haven't seen
any clear resolution.

Does anyone have a code snippet that works?

Can someone please advise?

Thanks,

TC
You can use My namepsace to upload to FTP server also by passing
credentials if required in the same code syntax:

"My.Computer.Network.UploadFile" method
http://msdn.microsoft.com/en-us/library/dfkdh7eb.aspx

Hope this helps,

Onur Güzel

Jul 29 '08 #2
On Jul 29, 7:10 am, "TC" <getmyemai...@yahoo.comwrote:
Hey All,

I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.

Unfortunately, I'm receiving a "Not Logged In" error.

I know that others have seen this as I've seen postings but I haven't seen
any clear resolution.

Does anyone have a code snippet that works?

Can someone please advise?

Thanks,

TC
I'm not sure if this is what you are looking for, but this is how I am
uploading a file to my ftp site.

'Variables
Dim local_file As String = path & filename
Dim remote_file As String = ftpsite & filename
Dim cls_request As System.Net.FtpWebRequest =
DirectCast(System.Net.WebRequest.Create(remote_fil e),
System.Net.FtpWebRequest)
Dim user_name As String = user
Dim password As String = password

'Establish credentials for logging into ftp site
cls_request.Credentials = New
System.Net.NetworkCredential(user_name, password)

'Set properties
cls_request.KeepAlive = False
cls_request.Proxy = Nothing
cls_request.Method =
System.Net.WebRequestMethods.Ftp.UploadFile
cls_request.UseBinary = True

'Read in the file
Dim b_file() As Byte = System.IO.File.ReadAllBytes(local_file)

'Upload the file
Dim cls_stream As System.IO.Stream =
cls_request.GetRequestStream()
cls_stream.Write(b_file, 0, b_file.Length)
cls_stream.Close()
cls_stream.Dispose()

This does overwrite files if they already exist.

Hope this helps,

Steve
Jul 29 '08 #3
TC
Hey Steve,

When I try to get the stream, it fails with this error:

The remote server returned an error: (550) File unavailable (e.g., file not
found, no access).

Any ideas?

I'm wondering if the URL I was given is the culprit. It is:

ftp://myserverurl.com/../companyname/Incoming/Orders/

Would the "/../" cause problems?

Thanks,

Todd
"Steve" <si*******@gmail.comwrote in message
news:c3**********************************@p10g2000 prf.googlegroups.com...
On Jul 29, 7:10 am, "TC" <getmyemai...@yahoo.comwrote:
>Hey All,

I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.

Unfortunately, I'm receiving a "Not Logged In" error.

I know that others have seen this as I've seen postings but I haven't
seen
any clear resolution.

Does anyone have a code snippet that works?

Can someone please advise?

Thanks,

TC

I'm not sure if this is what you are looking for, but this is how I am
uploading a file to my ftp site.

'Variables
Dim local_file As String = path & filename
Dim remote_file As String = ftpsite & filename
Dim cls_request As System.Net.FtpWebRequest =
DirectCast(System.Net.WebRequest.Create(remote_fil e),
System.Net.FtpWebRequest)
Dim user_name As String = user
Dim password As String = password

'Establish credentials for logging into ftp site
cls_request.Credentials = New
System.Net.NetworkCredential(user_name, password)

'Set properties
cls_request.KeepAlive = False
cls_request.Proxy = Nothing
cls_request.Method =
System.Net.WebRequestMethods.Ftp.UploadFile
cls_request.UseBinary = True

'Read in the file
Dim b_file() As Byte = System.IO.File.ReadAllBytes(local_file)

'Upload the file
Dim cls_stream As System.IO.Stream =
cls_request.GetRequestStream()
cls_stream.Write(b_file, 0, b_file.Length)
cls_stream.Close()
cls_stream.Dispose()

This does overwrite files if they already exist.

Hope this helps,

Steve

Jul 30 '08 #4
TC
Got it to work!

Turns out there was a problem with the URL that I was given. Once I had the
appropriate syntax, I was OK.

By the way, is there any reason one would use:

My.Computer.Network.UploadFile

vs.

the more verbose FtpWebRequest?

It seems that the My.Computer.Network.UploadFile method is very concise and
elegant. However, if more control is required, the latter may be a better
choice. But if all one really needs to do is upload, wouldn't the first be
a better choice?

Thanks,

Todd
"TC" <ge**********@yahoo.comwrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
Hey All,

I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.

Unfortunately, I'm receiving a "Not Logged In" error.

I know that others have seen this as I've seen postings but I haven't seen
any clear resolution.

Does anyone have a code snippet that works?

Can someone please advise?

Thanks,

TC


Jul 30 '08 #5
On Jul 29, 8:22 pm, "TC" <getmyemai...@yahoo.comwrote:
Got it to work!

Turns out there was a problem with the URL that I was given. Once I had the
appropriate syntax, I was OK.

By the way, is there any reason one would use:

My.Computer.Network.UploadFile

vs.

the more verbose FtpWebRequest?

It seems that the My.Computer.Network.UploadFile method is very concise and
elegant. However, if more control is required, the latter may be a better
choice. But if all one really needs to do is upload, wouldn't the first be
a better choice?

Thanks,

Todd

"TC" <getmyemai...@yahoo.comwrote in message

news:OQ**************@TK2MSFTNGP04.phx.gbl...
Hey All,
I'm trying to upload files via FTP and I'm using FtpWebRequest and
WebClient.
Unfortunately, I'm receiving a "Not Logged In" error.
I know that others have seen this as I've seen postings but I haven't seen
any clear resolution.
Does anyone have a code snippet that works?
Can someone please advise?
Thanks,
TC
I'm not to sure about that. I have been using the FtpWebRequest
method which has been working well for me. Maybe a MSFT MVP could
help you on that one.

Glad to know if worked for you.

Steve
Jul 30 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Beryl Small | last post by:
I have a web application in Visual Studio.Net 2003. On the click event of a button on my .aspx page, I use the following FileCopy SourceFile, DestinationFil the Sourcefile is on a mapped drive...
0
by: Mec | last post by:
Some time ago I created a windows forms application with a deployment project. I was always able to build the deployment package after changing the windows forms application, but somehow something...
4
by: mattsthompson | last post by:
Im writing a DLL that extends IHttpHandler to intercept requests for a certain file extension and deliver watermarked images. I'm using LeadTools' .NET framework for the image manipulation and it...
2
by: Sush | last post by:
Hi, I have a wtriiten a program in VB 6.0, and I have HTML files included for Help. I have declared Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _ (ByVal hWndCaller As...
10
by: Eric | last post by:
Hello, I have some server side includes on a Classic asp page that look something like: <!-- #include virtual="/includes/file1.asp"--> <!-- #include virtual="/includes/file2.asp" --> <!--...
0
by: active | last post by:
Sometimes when I After I click "Start Debugging" I get a "File not Found" Exception. Could not load file or assembly 'FormTesting, Version=1.0.2646.36738, Culture=neutral, PublicKeyToken=null'...
9
by: Jankie | last post by:
<?php if(isset($_POST) && $_FILES > 0){ foreach ($_FILES as $key => $error) { $name = $_FILES; $tempname = $_FILES; ………… ……… $path = 'uploads/'; include 'dbcon.php'; $rep = strpos($_FILES,...
1
by: gflor16 | last post by:
Here is the sample code: For Each strFile As String In My.Computer.FileSystem.GetFiles("c:\") lstData.Items.Add(strFile) If strFile.ToString.StartsWith("c:\IO")...
6
by: mlevit | last post by:
I'm trying to upload a file. I use to get the fread(): supplied argument is not a valid stream resource error, but then I placed the code in an if statement with file_exists. The problem is, the...
0
isladogs
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...
1
isladogs
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...
0
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.