Uploading entire directory

Discussion in 'ASP .Net' started by VB Programmer, May 9, 2005.

  1. I know how to upload an individual file to a server (See below code
    snippet).

    QUESTION: Is there an easy way to upload an entire subdirectory and all
    it's files? Or, do I have to loop thru the dir and upload them 1 by 1?

    This is the way I'm uploading the file...

    Dim strFileName As String
    strFileName = MyFile.PostedFile.FileName
    Dim c As String = System.IO.Path.GetFileName(strFileName) ' only the
    attched file name not its path

    ' Let us Save uploaded file to server
    Try
    MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("NewsletterFileDir")
    + c)
    Span1.InnerHtml = "Your File Uploaded Sucessfully: " &
    ConfigurationSettings.AppSettings("NewsletterFileDir") & c
    Catch Exp As Exception
    Span1.InnerHtml = "An Error occured. Please check the attached
    file"
    End Try
    VB Programmer, May 9, 2005
    #1
    1. Advertising

  2. The entire Directory!!!!
    Can't u let it create a directory before uploading files or just ove files?


    "VB Programmer" wrote:

    > I know how to upload an individual file to a server (See below code
    > snippet).
    >
    > QUESTION: Is there an easy way to upload an entire subdirectory and all
    > it's files? Or, do I have to loop thru the dir and upload them 1 by 1?
    >
    > This is the way I'm uploading the file...
    >
    > Dim strFileName As String
    > strFileName = MyFile.PostedFile.FileName
    > Dim c As String = System.IO.Path.GetFileName(strFileName) ' only the
    > attched file name not its path
    >
    > ' Let us Save uploaded file to server
    > Try
    > MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("NewsletterFileDir")
    > + c)
    > Span1.InnerHtml = "Your File Uploaded Sucessfully: " &
    > ConfigurationSettings.AppSettings("NewsletterFileDir") & c
    > Catch Exp As Exception
    > Span1.InnerHtml = "An Error occured. Please check the attached
    > file"
    > End Try
    >
    >
    >
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, May 10, 2005
    #2
    1. Advertising

  3. The standard File control allows only one file to be specified for upload.
    If you need to upload 2 files, then the simplest solution is to have 2 File
    controls on the page.
    There are fancier options, but they generally require thick clients. Here
    are some 3rd party options that may help you out:
    http://fileup.softartisans.com/fileup-231.aspx
    http://fileup.softartisans.com/fileup-131.aspx

    More info:
    http://SteveOrr.net/articles/EasyUploads.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "VB Programmer" <> wrote in message
    news:...
    >I know how to upload an individual file to a server (See below code
    >snippet).
    >
    > QUESTION: Is there an easy way to upload an entire subdirectory and all
    > it's files? Or, do I have to loop thru the dir and upload them 1 by 1?
    >
    > This is the way I'm uploading the file...
    >
    > Dim strFileName As String
    > strFileName = MyFile.PostedFile.FileName
    > Dim c As String = System.IO.Path.GetFileName(strFileName) ' only
    > the attched file name not its path
    >
    > ' Let us Save uploaded file to server
    > Try
    >
    > MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("NewsletterFileDir")
    > + c)
    > Span1.InnerHtml = "Your File Uploaded Sucessfully: " &
    > ConfigurationSettings.AppSettings("NewsletterFileDir") & c
    > Catch Exp As Exception
    > Span1.InnerHtml = "An Error occured. Please check the attached
    > file"
    > End Try
    >
    Steve C. Orr [MVP, MCSD], May 10, 2005
    #3
  4. Orr for President. Thanks.

    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:%...
    > The standard File control allows only one file to be specified for upload.
    > If you need to upload 2 files, then the simplest solution is to have 2
    > File controls on the page.
    > There are fancier options, but they generally require thick clients. Here
    > are some 3rd party options that may help you out:
    > http://fileup.softartisans.com/fileup-231.aspx
    > http://fileup.softartisans.com/fileup-131.aspx
    >
    > More info:
    > http://SteveOrr.net/articles/EasyUploads.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "VB Programmer" <> wrote in message
    > news:...
    >>I know how to upload an individual file to a server (See below code
    >>snippet).
    >>
    >> QUESTION: Is there an easy way to upload an entire subdirectory and all
    >> it's files? Or, do I have to loop thru the dir and upload them 1 by 1?
    >>
    >> This is the way I'm uploading the file...
    >>
    >> Dim strFileName As String
    >> strFileName = MyFile.PostedFile.FileName
    >> Dim c As String = System.IO.Path.GetFileName(strFileName) ' only
    >> the attched file name not its path
    >>
    >> ' Let us Save uploaded file to server
    >> Try
    >>
    >> MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("NewsletterFileDir")
    >> + c)
    >> Span1.InnerHtml = "Your File Uploaded Sucessfully: " &
    >> ConfigurationSettings.AppSettings("NewsletterFileDir") & c
    >> Catch Exp As Exception
    >> Span1.InnerHtml = "An Error occured. Please check the attached
    >> file"
    >> End Try
    >>

    >
    >
    VB Programmer, May 10, 2005
    #4
  5. VB Programmer

    gabe garza Guest

    Within a FORM tag you can specify several INPUT tags of type=FILE to upload
    several files but the user must select each of the files to upload.

    Yes HTML specifications has limitations (for good reasons) but if you really
    need to go outside of the HTML specification write a Windows Application not
    a Web Based Application..
    Don't compromise security. Every developer has good intentions but hackers
    don't. Think like a hacker to write better secured web applications or to
    decided whether a Web Based application is what you should be developing.


    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:%...
    > The standard File control allows only one file to be specified for upload.
    > If you need to upload 2 files, then the simplest solution is to have 2
    > File controls on the page.
    > There are fancier options, but they generally require thick clients. Here
    > are some 3rd party options that may help you out:
    > http://fileup.softartisans.com/fileup-231.aspx
    > http://fileup.softartisans.com/fileup-131.aspx
    >
    > More info:
    > http://SteveOrr.net/articles/EasyUploads.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "VB Programmer" <> wrote in message
    > news:...
    >>I know how to upload an individual file to a server (See below code
    >>snippet).
    >>
    >> QUESTION: Is there an easy way to upload an entire subdirectory and all
    >> it's files? Or, do I have to loop thru the dir and upload them 1 by 1?
    >>
    >> This is the way I'm uploading the file...
    >>
    >> Dim strFileName As String
    >> strFileName = MyFile.PostedFile.FileName
    >> Dim c As String = System.IO.Path.GetFileName(strFileName) ' only
    >> the attched file name not its path
    >>
    >> ' Let us Save uploaded file to server
    >> Try
    >>
    >> MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("NewsletterFileDir")
    >> + c)
    >> Span1.InnerHtml = "Your File Uploaded Sucessfully: " &
    >> ConfigurationSettings.AppSettings("NewsletterFileDir") & c
    >> Catch Exp As Exception
    >> Span1.InnerHtml = "An Error occured. Please check the attached
    >> file"
    >> End Try
    >>

    >
    >
    gabe garza, May 11, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MS News \(MS ILM\)
    Replies:
    1
    Views:
    417
    Scott Schluer
    Aug 19, 2003
  2. Xavier MT
    Replies:
    1
    Views:
    589
    Scott Schluer
    Aug 19, 2003
  3. =?Utf-8?B?Qm9uYXRvIFBpZXJhbnRvbmlv?=

    Upload Entire Directory

    =?Utf-8?B?Qm9uYXRvIFBpZXJhbnRvbmlv?=, Oct 29, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,216
    Martin Carolan
    Oct 29, 2004
  4. Dung Ping
    Replies:
    10
    Views:
    952
    Chaddy2222
    Jan 16, 2006
  5. Schultz

    Zip an entire directory tree

    Schultz, Dec 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    482
    Peter Bromberg [C# MVP]
    Dec 25, 2007
Loading...

Share This Page