This is a migrated thread and some comments may be shown as answers.

Save into DB Path

2 Answers 80 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 19 Jan 2010, 03:22 AM
hi

This is the path i have save into the DB:

/upload/9d08d0640453a041f10b5b307bcfffa7fd71\9d08d0640453a041f10b5b307bcfffa7fd71.pdf

did you notice that / / \ slashes? How do i change the \ to /?

and this is the code:

Dim filename As String = System.Guid.NewGuid().ToString.Replace("-", "0")
        Dim filepath As String = "~/upload/" & filename
        Directory.CreateDirectory(Server.MapPath(filepath))
        For Each f As UploadedFile In RadUpload1.UploadedFiles
            f.SaveAs(Path.Combine(Server.MapPath(filepath), filename + f.GetExtension))
           Save(Path.Combine(filepath, filename + f.GetExtension).ToString)
 Next

Will i have any problems if i would to just leave it as it is?

2 Answers, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 19 Jan 2010, 12:07 PM
Hi L,

This is because you have saved the path relative to the upload folder, not the full file path. The / slash delimits relative paths whereas the \ slash delimits the path as opposed to the file system. In order to save the full path you your database modify the following line

Save(Path.Combine(filepath, filename + f.GetExtension).ToString)

to

Save(Path.Combine(Server.MapPath(filepath), filename + f.GetExtension).ToString)


Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
L
Top achievements
Rank 1
answered on 19 Jan 2010, 02:27 PM
hi

I finally got it working:

Path.Combine(filepath, filename + f.GetExtension).ToString.Replace(

"\", "/")

Thanks

 

Tags
Upload (Obsolete)
Asked by
L
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
L
Top achievements
Rank 1
Share this question
or