re:[color=blue]
>I didn't specify that directory[/color]
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" <CSharpguy@discussions.microsoft.com> wrote in message
news:7759E6DD-C770-4C01-9CA9-C07CDAA88D43@microsoft.com...[color=blue]
>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[/color]
[color=blue]
> "Juan T. Llibre" wrote:[/color]
[color=blue][color=green]
>> re:[color=darkred]
>> > when I try and download a file I get "access denied to c:\windows\system32\ftptest.txt"[/color]
>>
>> 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" <CSharpguy@discussions.microsoft.com> wrote in message
>> news:FEFFF6CD-00DE-49AA-B3D6-658E88E31443@microsoft.com...[color=darkred]
>> > 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" <CSharpguy@discussions.microsoft.com> wrote in message
>> >> news:CE5BE3DA-5716-46EF-B01D-522A2085C38C@microsoft.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" <nomailreplies@nowhere.com> wrote in message
>> >> >> news:OzMOzjsaGHA.3444@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" <CSharpguy@discussions.microsoft.com> wrote in message
>> >> >> > news:456D9AFD-5B3C-456A-82E4-72EE27D26D8D@microsoft.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?
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>[/color]
>>
>>
>>[/color][/color]