Welcome to WebmasterWorld Guest from 54.226.175.101

Forum Moderators: ocean10000

Message Too Old, No Replies

Upload UNC path problem

     
8:41 pm on Aug 10, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


I am trying to create a file uploader but am running into a problem with UNC paths. I get an error saying

Server Error in '/' Application.
'C:\Users\username\Desktop\folder\Drawings\DrawingProduct-21Drive Train.pdf' is not a valid virtual path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 'C:\Users\username\Desktop\folder\Drawings\DrawingProduct-21Drive Train.pdf' is not a valid virtual path.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Now I know that the error is because this file is located on a mapped drive. I'm guessing that the server needs the real path i.e. \\servername\folder\file.pdf. What I don't know is how to do that here is my vb uploading code. Let me know if I need to post more. Thanks,


If Page.IsValid Then

For Each validFile As UploadedFile In DrawingPDFRadUpload.UploadedFiles
Dim targetFolder As String = Server.MapPath("~/admin/products/Documents/Drawings/")
validFile.SaveAs(Path.Combine(targetFolder, "DrawingProduct" & productId & validFile.GetName()), True)
Me.drawingsSqlDataSource.InsertParameters("PathToPDF").DefaultValue = "~/admin/products/Documents/Drawings/" & "DrawingProduct" & productId & validFile.GetName()
Next
For Each validFile As UploadedFile In PartsRadUpload.UploadedFiles
Dim targetFolder As String = Server.MapPath("~/admin/Temp/")
validFile.SaveAs(Path.Combine(targetFolder, "XLSProduct" & productId & validFile.GetName()), True)
Me.drawingsSqlDataSource.InsertParameters("sourceFile").DefaultValue = Path.Combine(targetFolder, "XLSProduct" & productId & validFile.GetName())
Next
Me.drawingsSqlDataSource.InsertParameters("productId").DefaultValue = productId
Try
Me.drawingsSqlDataSource.Insert()
Catch ex As Exception

End Try

Me.AddButton.Visible = False
Me.updateButton.Visible = True
Me.drawingsToolTip.Visible = False
End If

4:52 am on Aug 11, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


I think the Telerik controls also attempt a Server.MapPath on 'targetFolder' try calling validFile.SaveAs with a virtual path instead of a fixed path.

If this is not the case, when exactly does this error occur? (which line of code) The file path given also seems to relate to the file being uploaded and not the save location.

Also remember that you are using a third party control, you can best ask questions about this in the Telerik Support Area.

1:36 pm on Aug 11, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


It was a target path error you are correct. I usually post on the telerik site, but they take like 3 days to answer a question and I'm just kind of partial to webmasters. I fixed it, I just didn't have the path correct that it was saving too.