473,324 Members | 2,511 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,324 software developers and data experts.

connect to FTP server

I need to upload a file to an FTP server, can someone point me to some code
that connects to an FTP server and uploads a file?
Apr 28 '06 #1
15 2160
where? what link is it under? i went to all 3 and didn't see anything on FTP

"Swanand Mokashi" wrote:
Here is a class I wrote for FTP connections. See if it is useful to you

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I need to upload a file to an FTP server, can someone point me to some code
that connects to an FTP server and uploads a file?


Apr 28 '06 #2
Here's a full-featured, free, FTP Client Library, written in C# :

http://www.c-sharpcorner.com/UploadF...FtpClient.aspx

It's less than 6KB in size.

Here's another example :
http://www.hotscripts.com/Detailed/40607.html

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I need to upload a file to an FTP server, can someone point me to some code
that connects to an FTP server and uploads a file?

Apr 28 '06 #3
It's in a text file, as an attachment to his post.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
where? what link is it under? i went to all 3 and didn't see anything on FTP

"Swanand Mokashi" wrote:
Here is a class I wrote for FTP connections. See if it is useful to you

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
>I need to upload a file to an FTP server, can someone point me to some code
> that connects to an FTP server and uploads a file?
>
>


Apr 28 '06 #4
It is in the attachement.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
where? what link is it under? i went to all 3 and didn't see anything on
FTP

"Swanand Mokashi" wrote:
Here is a class I wrote for FTP connections. See if it is useful to you

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
>I need to upload a file to an FTP server, can someone point me to some
>code
> that connects to an FTP server and uploads a file?
>
>


Apr 28 '06 #5
I might mention that these should be construed as examples. I had to write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc) built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
Here's a full-featured, free, FTP Client Library, written in C# :

http://www.c-sharpcorner.com/UploadF...FtpClient.aspx

It's less than 6KB in size.

Here's another example :
http://www.hotscripts.com/Detailed/40607.html

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I need to upload a file to an FTP server, can someone point me to some
code
that connects to an FTP server and uploads a file?


Apr 28 '06 #6
Good points, Kevin.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eU**************@TK2MSFTNGP02.phx.gbl...
I might mention that these should be construed as examples. I had to write an FTP client, and the
Socket connection and related functionality is not difficult at all. What *is* difficult is
handling the various network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc) built into it.

Another issue is that some of the format of the returned data, such as directory listing and
system status, is not standardized, and can be difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
Here's a full-featured, free, FTP Client Library, written in C# :

http://www.c-sharpcorner.com/UploadF...FtpClient.aspx

It's less than 6KB in size.

Here's another example :
http://www.hotscripts.com/Detailed/40607.html

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I need to upload a file to an FTP server, can someone point me to some code
that connects to an FTP server and uploads a file?



Apr 28 '06 #7
I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:
I might mention that these should be construed as examples. I had to write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc) built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
Here's a full-featured, free, FTP Client Library, written in C# :

http://www.c-sharpcorner.com/UploadF...FtpClient.aspx

It's less than 6KB in size.

Here's another example :
http://www.hotscripts.com/Detailed/40607.html

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I need to upload a file to an FTP server, can someone point me to some
code
that connects to an FTP server and uploads a file?



Apr 28 '06 #8
The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:
I might mention that these should be construed as examples. I had to
write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc)
built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
> Here's a full-featured, free, FTP Client Library, written in C# :
>
> http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>
> It's less than 6KB in size.
>
> Here's another example :
> http://www.hotscripts.com/Detailed/40607.html
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
> news:45**********************************@microsof t.com...
>>I need to upload a file to an FTP server, can someone point me to some
>>code
>> that connects to an FTP server and uploads a file?
>>
>>
>
>


Apr 28 '06 #9
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
where? what link is it under? i went to all 3 and didn't see anything on
FTP


It was in an attachment to the reply. Your newsreader is probably set to
remove all attachments to posts - mine certainly is...
Apr 28 '06 #10
I'm using the code and I'm getting 'access denie to file c:\ftptest.txt"
file, or I get False returned. Do i need to do anything on my box other then
the code? I'm logged into the FTP server (via a gui) to see if my file is
getting uploaded and its not, also when I try and download a file I get
"access denied to c:\windows\system32\ftptest.txt"

whats missing

"Swanand Mokashi" wrote:
The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:
I might mention that these should be construed as examples. I had to
write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc)
built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
> Here's a full-featured, free, FTP Client Library, written in C# :
>
> http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>
> It's less than 6KB in size.
>
> Here's another example :
> http://www.hotscripts.com/Detailed/40607.html
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
> news:45**********************************@microsof t.com...
>>I need to upload a file to an FTP server, can someone point me to some
>>code
>> that connects to an FTP server and uploads a file?
>>
>>
>
>


Apr 28 '06 #11
I'm using this buy they way:

http://www.c-sharpcorner.com/UploadF...FtpClient.aspx

"Swanand Mokashi" wrote:
The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:
I might mention that these should be construed as examples. I had to
write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc)
built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
> Here's a full-featured, free, FTP Client Library, written in C# :
>
> http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>
> It's less than 6KB in size.
>
> Here's another example :
> http://www.hotscripts.com/Detailed/40607.html
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
> news:45**********************************@microsof t.com...
>>I need to upload a file to an FTP server, can someone point me to some
>>code
>> that connects to an FTP server and uploads a file?
>>
>>
>
>


Apr 28 '06 #12
re:
when I try and download a file I get "access denied to c:\windows\system32\ftptest.txt"
You need to specify a directory which isn't security-conscious
as the destination for the uploaded files.

I'd *never* upload files to that directory.

Also, if you're getting "access denied", the account ASP.NET is running as
doesn't have enough permissions to access the file and/or directory.

Save the following code as "identity.aspx" and run the file.

identity.aspx
=========
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
======

Then, assign access permissions for the file/directory to the account which that file returns.

Remember to change the upload directory to an ad-hoc directory.
Don't use c:\windows\system32\ as your upload directory.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com... I'm using the code and I'm getting 'access denie to file c:\ftptest.txt"
file, or I get False returned. Do i need to do anything on my box other then
the code? I'm logged into the FTP server (via a gui) to see if my file is
getting uploaded and its not, also when I try and download a file I get
"access denied to c:\windows\system32\ftptest.txt"

whats missing

"Swanand Mokashi" wrote:
The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> I'll consider that as well, but all I need to do realy is upload the file
> then check to confirm it got there.
>
> "Kevin Spencer" wrote:
>
>> I might mention that these should be construed as examples. I had to
>> write
>> an FTP client, and the Socket connection and related functionality is not
>> difficult at all. What *is* difficult is handling the various
>> network-related issues that can arise. For an FTP client to be robust, it
>> needs to have a lot of recovery functionality (retries, timers, etc)
>> built
>> into it.
>>
>> Another issue is that some of the format of the returned data, such as
>> directory listing and system status, is not standardized, and can be
>> difficult to parse.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Hard work is a medication for which
>> there is no placebo.
>>
>> "Juan T. Llibre" <no***********@nowhere.com> wrote in message
>> news:Oz**************@TK2MSFTNGP05.phx.gbl...
>> > Here's a full-featured, free, FTP Client Library, written in C# :
>> >
>> > http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>> >
>> > It's less than 6KB in size.
>> >
>> > Here's another example :
>> > http://www.hotscripts.com/Detailed/40607.html
>> >
>> >
>> >
>> > Juan T. Llibre, asp.net MVP
>> > aspnetfaq.com : http://www.aspnetfaq.com/
>> > asp.net faq : http://asp.net.do/faq/
>> > foros de asp.net, en español : http://asp.net.do/foros/
>> > ===================================
>> > "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
>> > news:45**********************************@microsof t.com...
>> >>I need to upload a file to an FTP server, can someone point me to some
>> >>code
>> >> that connects to an FTP server and uploads a file?
>> >>
>> >>
>> >
>> >
>>
>>
>>


Apr 28 '06 #13
I didn't specify that directory, when I was trying to pull down the file it
tried and dump it there. I have an upload directory I'm working on pulling
the files from

"Juan T. Llibre" wrote:
re:
when I try and download a file I get "access denied to c:\windows\system32\ftptest.txt"


You need to specify a directory which isn't security-conscious
as the destination for the uploaded files.

I'd *never* upload files to that directory.

Also, if you're getting "access denied", the account ASP.NET is running as
doesn't have enough permissions to access the file and/or directory.

Save the following code as "identity.aspx" and run the file.

identity.aspx
=========
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
======

Then, assign access permissions for the file/directory to the account which that file returns.

Remember to change the upload directory to an ad-hoc directory.
Don't use c:\windows\system32\ as your upload directory.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
I'm using the code and I'm getting 'access denie to file c:\ftptest.txt"
file, or I get False returned. Do i need to do anything on my box other then
the code? I'm logged into the FTP server (via a gui) to see if my file is
getting uploaded and its not, also when I try and download a file I get
"access denied to c:\windows\system32\ftptest.txt"

whats missing

"Swanand Mokashi" wrote:
The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> I'll consider that as well, but all I need to do realy is upload the file
> then check to confirm it got there.
>
> "Kevin Spencer" wrote:
>
>> I might mention that these should be construed as examples. I had to
>> write
>> an FTP client, and the Socket connection and related functionality is not
>> difficult at all. What *is* difficult is handling the various
>> network-related issues that can arise. For an FTP client to be robust, it
>> needs to have a lot of recovery functionality (retries, timers, etc)
>> built
>> into it.
>>
>> Another issue is that some of the format of the returned data, such as
>> directory listing and system status, is not standardized, and can be
>> difficult to parse.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Hard work is a medication for which
>> there is no placebo.
>>
>> "Juan T. Llibre" <no***********@nowhere.com> wrote in message
>> news:Oz**************@TK2MSFTNGP05.phx.gbl...
>> > Here's a full-featured, free, FTP Client Library, written in C# :
>> >
>> > http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>> >
>> > It's less than 6KB in size.
>> >
>> > Here's another example :
>> > http://www.hotscripts.com/Detailed/40607.html
>> >
>> >
>> >
>> > Juan T. Llibre, asp.net MVP
>> > aspnetfaq.com : http://www.aspnetfaq.com/
>> > asp.net faq : http://asp.net.do/faq/
>> > foros de asp.net, en español : http://asp.net.do/foros/
>> > ===================================
>> > "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
>> > news:45**********************************@microsof t.com...
>> >>I need to upload a file to an FTP server, can someone point me to some
>> >>code
>> >> that connects to an FTP server and uploads a file?
>> >>
>> >>
>> >
>> >
>>
>>
>>


Apr 28 '06 #14
re:
I didn't specify that directory
Clearly.

That's why I suggested that you *do* specify it.
private void Page_Load(object sender, System.EventArgs e)
{
/*
* Set the "path" variable to the location where files are to be stored
*/
string path = "../docs";

HttpFileCollection files;
files = Page.Request.Files;
for(int index=0; index < files.AllKeys.Length; index++)
{
HttpPostedFile postedFile = files[index];
string fileName = null;
int lastPos = postedFile.FileName.LastIndexOf('\\');
fileName = postedFile.FileName.Substring(++lastPos);
//Check the file type through the extension
if(fileName.EndsWith("doc") || fileName.EndsWith("doc") ||
fileName.EndsWith("pdf") || fileName.EndsWith("pdf")
{
postedFile.SaveAs(MapPath(path + "/" + fileName));
}
}
}

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...I didn't specify that directory, when I was trying to pull down the file it
tried and dump it there. I have an upload directory I'm working on pulling
the files from "Juan T. Llibre" wrote:

re:
> when I try and download a file I get "access denied to c:\windows\system32\ftptest.txt"


You need to specify a directory which isn't security-conscious
as the destination for the uploaded files.

I'd *never* upload files to that directory.

Also, if you're getting "access denied", the account ASP.NET is running as
doesn't have enough permissions to access the file and/or directory.

Save the following code as "identity.aspx" and run the file.

identity.aspx
=========
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
======

Then, assign access permissions for the file/directory to the account which that file returns.

Remember to change the upload directory to an ad-hoc directory.
Don't use c:\windows\system32\ as your upload directory.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
> I'm using the code and I'm getting 'access denie to file c:\ftptest.txt"
> file, or I get False returned. Do i need to do anything on my box other then
> the code? I'm logged into the FTP server (via a gui) to see if my file is
> getting uploaded and its not, also when I try and download a file I get
> "access denied to c:\windows\system32\ftptest.txt"
>
> whats missing
>
> "Swanand Mokashi" wrote:
>
>> The sample code I attached should let you do that.
>>
>> --
>> Swanand Mokashi
>> Microsoft Certified Solution Developer (.NET) - Early Achiever
>> Microsoft Certified Application Developer (.NET)
>>
>> http://www.dotnetgenerics.com/
>> DotNetGenerics.com -- anything and everything about Microsoft .NET
>> technology ...
>>
>> http://www.swanandmokashi.com/
>> http://www.swanandmokashi.com/HomePage/WebServices/
>> Home of the Stock Quotes, Quote of the day and Horoscope web services
>>
>>
>> "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
>> news:CE**********************************@microsof t.com...
>> > I'll consider that as well, but all I need to do realy is upload the file
>> > then check to confirm it got there.
>> >
>> > "Kevin Spencer" wrote:
>> >
>> >> I might mention that these should be construed as examples. I had to
>> >> write
>> >> an FTP client, and the Socket connection and related functionality is not
>> >> difficult at all. What *is* difficult is handling the various
>> >> network-related issues that can arise. For an FTP client to be robust, it
>> >> needs to have a lot of recovery functionality (retries, timers, etc)
>> >> built
>> >> into it.
>> >>
>> >> Another issue is that some of the format of the returned data, such as
>> >> directory listing and system status, is not standardized, and can be
>> >> difficult to parse.
>> >>
>> >> --
>> >> HTH,
>> >>
>> >> Kevin Spencer
>> >> Microsoft MVP
>> >> Professional Numbskull
>> >>
>> >> Hard work is a medication for which
>> >> there is no placebo.
>> >>
>> >> "Juan T. Llibre" <no***********@nowhere.com> wrote in message
>> >> news:Oz**************@TK2MSFTNGP05.phx.gbl...
>> >> > Here's a full-featured, free, FTP Client Library, written in C# :
>> >> >
>> >> > http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>> >> >
>> >> > It's less than 6KB in size.
>> >> >
>> >> > Here's another example :
>> >> > http://www.hotscripts.com/Detailed/40607.html
>> >> >
>> >> >
>> >> >
>> >> > Juan T. Llibre, asp.net MVP
>> >> > aspnetfaq.com : http://www.aspnetfaq.com/
>> >> > asp.net faq : http://asp.net.do/faq/
>> >> > foros de asp.net, en español : http://asp.net.do/foros/
>> >> > ===================================
>> >> > "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
>> >> > news:45**********************************@microsof t.com...
>> >> >>I need to upload a file to an FTP server, can someone point me to some
>> >> >>code
>> >> >> that connects to an FTP server and uploads a file?
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>



Apr 28 '06 #15
> I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.
To do that, you need to connect your Socket first, wait for a response from
the server, verify the response, send a PASV command to the server, open
your data connection, write the file to the server, close your data
connection, and then wait for a response from the server on your Command
connection.

Any of these can fail over a network, even though they rarely do. That's
what I was talking about. It can be a real nightmare trying to figure out
what went wrong if you don't account for every possibility.

As for your problems with the file upload, be sure that you specify the
absolute file path to your data connection for fetching the file, and a
root-relative path on the server for where you want to upload the file to.
In FTP, the root folder is the "lowest" folder you can access with your
account. This is referred to as "/" in FTP server paths. If you want to
upload the file to a folder underneath that folder, you would add the folder
name after the slash. For example, if the remote folder is:

C:\Inetpub\FtpRoot\folder1

It will be the folder "/" to your client. If you want to upload to

C:\Inetpub\FtpRoot\folder1\subfolder1

Your upload path will be
"/subfolder1/filename.xxx"

So, your command would be: "STOR /subfolder1/filename.xxx" + CRLF

Always be sure to check the response code, the first 3 characters in the
response. It will indicate whether or not the action succeeded. Your app may
not throw any exceptions, but fail to upload the file anyway.
--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com... I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:
I might mention that these should be construed as examples. I had to
write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc)
built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oz**************@TK2MSFTNGP05.phx.gbl...
> Here's a full-featured, free, FTP Client Library, written in C# :
>
> http://www.c-sharpcorner.com/UploadF...FtpClient.aspx
>
> It's less than 6KB in size.
>
> Here's another example :
> http://www.hotscripts.com/Detailed/40607.html
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "CSharpguy" <CS*******@discussions.microsoft.com> wrote in message
> news:45**********************************@microsof t.com...
>>I need to upload a file to an FTP server, can someone point me to some
>>code
>> that connects to an FTP server and uploads a file?
>>
>>
>
>


Apr 28 '06 #16

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

Similar topics

6
by: Jerry Orr | last post by:
We are trying to determine the easiest (and cheapest) way to get connections for about 50 Win2K workstations on our LAN to DB2 on a z/OS server. We could install DB2 Connect Personal Edition on...
4
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
5
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
14
by: DaTurk | last post by:
I am makeing a Multicast server client setup and was wondering what the difference is between Socket.Connect, and Socket.Bind. It may be a stupid question, but I was just curious. Because I...
0
by: Clodoaldo Pinto | last post by:
Can't connect to postgresql server php error log message: PHP Warning: pg_connect() : Unable to connect to PostgreSQL server: could not connect to server: Permission denied\n\tIs the server...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
0
by: tamayi | last post by:
I have a problem (like most others posting issues on this forum :) ) I have a remote server running Windows XP SP2, with both SQL Server 2005 Express with Advanced Features and SQL 2000...
7
by: RN1 | last post by:
Is it possible to connect to my local SQL Server 2005 database from a remote web server? If yes, what ConnectionString do I use? Thanks, Ron
0
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...
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: 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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.