Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2009, 09:47 PM
Authorized User
 
Join Date: Jul 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rooted Path Error

Thanks for your help!

I'm getting this error when I try to upload the picture file in LINQ chapter.

"
Quote:
The SaveAs method is configured to require a rooted path, and the path 'cd267bc1-a0ce-434c-bd50-0ca592d95b7b\ced06f37-df6c-4714-9679-a99c925da209.jpg' is not rooted."
I really don't understand this - my 'Pics' folder is I think at the root of the website. I went to the head of Solution Explorer, clicked on the website name and got a new folder 'Pics'. Isn't that at the root?

The website (PRI) is folded into wwroot.

This piece of code was highlighted in the error message:

[fileUpload1.SaveAs(System.IO.Path.Combine(physical folder, fileName + extension))
/]

?
 
Old September 2nd, 2009, 04:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi cortttt,

It looks like the variable physicalfolder is empty. Can you post the rest of the code in this method?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 2nd, 2009, 07:33 PM
Authorized User
 
Join Date: Jul 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks

Code:
 Protected Sub LinqDataSource1_Inserting1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceInsertEventArgs) Handles LinqDataSource1.Inserting

        Dim myPicture As Picture = CType(e.NewObject, Picture)
        myPicture.PhotoAlbumID = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumID"))
        Dim fileUpload1 As FileUpload = CType(ListView1.InsertItem.FindControl("FileUpload1"), FileUpload)
        Dim virtualFolder As String = "~/Pics/"
        Dim physicalfolder As String = Guid.NewGuid().ToString()
        Dim fileName As String = Guid.NewGuid().ToString()
        Dim extension As String = System.IO.Path.GetExtension(fileUpload1.FileName)

        fileUpload1.SaveAs(System.IO.Path.Combine(physicalfolder, fileName + extension))
        myPicture.ImageURL = virtualFolder + fileName + extension

    End Sub
 
Old September 2nd, 2009, 07:38 PM
Authorized User
 
Join Date: Jul 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see my mistake - physical folder has wrong code. When I first did this I put all that code in the wrong place; when I moved it to the right place something went very wrong - since about half of it was wrong

physicalfolder should = serverMapPath(virtualFolder)

Works great now- fantastic!

Last edited by cortttt; September 2nd, 2009 at 07:41 PM..
 
Old September 3rd, 2009, 06:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Excellent; glad it's working now...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR: Illegal characters in path owen_xgy .NET Framework 2.0 8 April 2nd, 2008 10:21 AM
Error while setting class path sujithmathew Linux 1 August 3rd, 2007 01:02 PM
FileUpload "Rooted" error rsearing ASP.NET 2.0 Basics 4 July 20th, 2007 01:17 AM
Error: Could not find a part of the path eelisMX Pro VB.NET 2002/2003 2 July 4th, 2006 02:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.