FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

Last post 08-29-2008 3:47 PM by Phillip J. 4 replies.

Sort Posts:

  • FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

    08-28-2008, 5:11 PM
    • Member
      59 point Member
    • Phillip J
    • Member since 08-11-2006, 1:26 PM
    • Ventura, CA.
    • Posts 203

    I have installed the FileUpload control on a web page and have found lots of good code to help with this task.

    I am stuck with the SaveAs method!

    All the examples show either hard coded paths or a known path from a root.

    How do save to a sub folder of the actual website?
    (i.e. I tried "~\Video\" and got an error saying it needed to be a root path)

    Thanks
    Phillip J.
    Ventura, Ca. USA/Savusavu, Fiji
  • Re: FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

    08-28-2008, 5:51 PM
    • All-Star
      90,407 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,382
    • Moderator
      TrustedFriends-MVPs

    Try this:

        protected void Button1_Click(object sender, EventArgs e)
        {     
             String FullPath = MapPath(@"~\Videos\");

    Steve Wellens

    My blog
  • Re: FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

    08-29-2008, 12:02 AM
    Answer
    • All-Star
      20,872 point All-Star
    • venkatu2005
    • Member since 07-01-2008, 10:48 AM
    • Posts 4,549

    Hai

    Use

    Server.Mappath("~/Video/" & Filename);
     

    I have Changed My Blog from (http://venkat-dotnetsamples.blogspot.com) to (http://venkat-dotnetsnippets.blogspot.com)

    Regards,
    Venkatesan.M

    Please Mark as Answered If its helpful and Un-Mark as Answered if it not help u.
  • Re: FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

    08-29-2008, 10:21 AM
    • Member
      59 point Member
    • Phillip J
    • Member since 08-11-2006, 1:26 PM
    • Ventura, CA.
    • Posts 203

    Oaky I'll buy into it that it has to be a ROOT not a /LocalHost/ type path...

    BUT

    I have the line below as per all teh examples and I still get an error... Can not find part of the path

    FileUpload1.SaveAs(Server.MapPath("~/Vidoe/") & FileUpload1.FileName)

    Does the path have a physical length max?  Here is mine!

      Server.MapPath("~/Vidoe/") & FileUpload1.FileName  = "C:\Documents and Settings\phillip_seaman\My Documents\Code\New Development\Wiki\PM2005_v2\Vidoe\intro.wmv" String

    What am I missing?

    Thanks
    Phillip J.
    Ventura, Ca. USA/Savusavu, Fiji
  • Re: FileUpload.SaveAs - how to save a file to a web site folder - unknown root path?

    08-29-2008, 3:47 PM
    • Member
      59 point Member
    • Phillip J
    • Member since 08-11-2006, 1:26 PM
    • Ventura, CA.
    • Posts 203

    Okay... MY BAD....

    I had someone else look at the line it was ALL MY FAULT... dahhh! do I feel stupid or what?

    I spelled Video wrong ... dahhh!

    Thanks for all the replies and help though!

    Thanks
    Phillip J.
    Ventura, Ca. USA/Savusavu, Fiji
Page 1 of 1 (5 items)
Microsoft Communities