Click here to Skip to main content
12,506,338 members (54,732 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Server
I've created a folder on runtime
and i want to upload some pices on it
put I've got this error message
(Could not find a part of the path )
when I refresh the parent folder It works well
now all what i want is to refresh the parent folder on runtime with code
thnx for your help
Posted 4-Oct-12 15:00pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You just have to make sure that you use Server.MapPath to get a "qualified" reference to the folder you created. You don't have to "refresh". In windows explorer you normally refresh to see if you created the folder from another explorer window. This does not apply to a web application. If you created, it's there already! And, post some code, it may help one of us find the issue.

Have a look at these links -

http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx[^]

http://www.4guysfromrolla.com/webtech/121799-1.shtml[^]
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

thank you very much for your Quick response

this is the code I use for create folders
Protected Sub Button10_Click(sender As Object, e As System.EventArgs) Handles Button10.Click
       If TextBox3.Text = Nothing Or TextBox4.Text = Nothing Then
           Exit Sub
       End If
       Dim Fname As String
       Dim path As String
       path = Request.PhysicalApplicationPath
       If FileUpload1.HasFile Then
           Fname = FileUpload1.FileName
           path += "\images\characters\"
           path += Fname
 
           FileUpload1.SaveAs(path)
       End If
 
       Dim linkpath As String = "abo-rashed.aspx?caracter=" + TextBox3.Text + "&txt=" + TextBox4.Text
       Session("caracter-name") = TextBox3.Text
 
       Dim doc As XDocument = XDocument.Load(CType(Session.Item("file"), String))
       'Dim ele As XElement = New XElement("comment", TextBox3.Text)
       Dim ele As XElement = New XElement("cd", "")
       doc.Root.AddFirst(ele)
 
       Dim ele2 As XElement = New XElement("title", "images\characters\" + Fname)
       Dim ele1 As XElement = New XElement("link", linkpath)
       Dim ele3 As XElement = New XElement("txt", linkpath)
 

 
       doc.Root.Element("cd").Add(ele1, ele2, ele3)
 

 
       doc.Save(CType(Session.Item("file"), String))
       mysource()
       '--------------------------------------------add folders---------------------------------
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text)
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\bg")
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\bg-real")
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\card")
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\card-real")
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\logo")
       Directory.CreateDirectory(Request.PhysicalApplicationPath & "images\caracter-main\" + TextBox3.Text + "\trach")
 

 
       Server.Transfer("AdminCaracters.aspx")
   End Sub

and this is the code I use for upload pices to one of this folders
Dim Fname1 As String
       Dim Fname2 As String
       Dim Fname3 As String
       Dim Fname4 As String
       Dim path1 As String
       Dim path2 As String
       Dim path3 As String
       Dim path4 As String
       Dim CNAME As String
       Dim pathlink As String
       If Not Session.Item("caracter-name") Is Nothing Then
           CNAME = Session.Item("caracter-name").ToString
       Else
           If Not TextBox3.Text = Nothing Then
               CNAME = TextBox3.Text
           End If
       End If
       If CNAME = Nothing Then
           Exit Sub
       End If
       pathlink = Request.PhysicalApplicationPath + "\images\caracter-main\" + CNAME + "\bg\"
 

       Fname1 = FileUpload2.FileName
       Fname2 = FileUpload3.FileName
       Fname3 = FileUpload4.FileName
       Fname4 = FileUpload5.FileName
 

       path1 = pathlink + Fname1
       path2 = pathlink + Fname2
       path3 = pathlink + Fname3
       path4 = pathlink + Fname4
 
       FileUpload2.SaveAs(path1)
       FileUpload3.SaveAs(path2)
       FileUpload4.SaveAs(path3)
       FileUpload5.SaveAs(path4)
 

 

 
   End Sub

and thank you again
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

about Server.MapPath it didn`t work
but thnx so much
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100