|
-
Dec 3rd, 2003, 05:21 PM
#1
Thread Starter
Frenzied Member
Saving uploaded file error
I am receiving this error
Could not find a part of the path
"c:\inetpub\wwwroot\www01\ESPEmail\df268d2c-5666-4171-a4a1-ca703ff3bce7\Test.doc".
I am trying to save an uploaded file to a dynamically created directory, but I keep getting the error above
Here is my code
VB Code:
Dim Filename As String = ""
'Declare a new directory to be created
Dim newDir As New DirectoryInfo(Server.MapPath("EmailAttachments\") & Guid.NewGuid.ToString)
'Grab the name of the file
Filename = Path.GetFileName(attachmentFile.PostedFile.FileName)
'Create the new directory
newDir.Create()
'Save the uploaded file to the new directory
attachmentFile.PostedFile.SaveAs(Server.MapPath(newDir.Name) & "\" & Filename)
'Add the filename to the listbox
lstAttachments.Items.Add(Filename)
It creates the new (GUID) directory just fine, it just doesn't save the file to it.
any ideas on how to fix this???
Last edited by Memnoch1207; Dec 3rd, 2003 at 05:51 PM.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 3rd, 2003, 05:51 PM
#2
Thread Starter
Frenzied Member
VB Code:
'I have also tried it with this line of code
'but I get the same error
attachmentFile.PostedFile.SaveAs(Server.MapPath(newDir.Name & "\") & Filename)
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 3rd, 2003, 06:15 PM
#3
PowerPoster
Don't know much about the upload, but does ASP.NET have permission to write that file to disk in that directory?
-
Dec 3rd, 2003, 10:11 PM
#4
Thread Starter
Frenzied Member
My assumption would be yes...Since it is actually creating the directory I would think that it would have permission to write the file into that directory as well.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 4th, 2003, 12:39 PM
#5
Thread Starter
Frenzied Member
actually, I got it to work like this
VB Code:
Dim Filename As String = ""
Dim newDir As New DirectoryInfo(Server.MapPath("EmailAttachments\\") & Guid.NewGuid.ToString)
Dim FilePath As String = ""
FilePath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "\EmailAttachments\\" & newDir.Name & "\\"
If (Directory.Exists(newDir.ToString) = False) Then
Response.Write(newDir.ToString & " doesn't exist")
newDir.Create()
End If
Filename = Path.GetFileName(attachmentFile.PostedFile.FileName)
attachmentFile.PostedFile.SaveAs(FilePath & Filename)
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|