Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Folder creation error: "Could not find a part of the path" error

Reply
Thread Tools

Folder creation error: "Could not find a part of the path" error

 
 
E. Kwong
Guest
Posts: n/a
 
      11-06-2006
Just a simple file upload form that allow files to be uploaded to a folder
named "media2". Code fragments are like these:

Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs)
If (upFile.HasFile) Then
If (CheckFileType(upFile.FileName)) Then
Dim filePath As String = "~/media2/" & upFile.FileName
upFile.SaveAs(MapPath(filePath))
lblUploadStatus.Text = upFile.FileName & " Content Type " &
upFile.PostedFile.ContentType & " Length " & upFile.PostedFile.ContentLength
& " uploaded"
Else
lblUploadStatus.Text = "File type not allowed"
End If
Else
lblUploadStatus.Text = "No file uploaded"
End If
End Sub

Sub Page_PreRender()
Dim upFolder As String = MapPath("~/media2/")
Dim dir As New DirectoryInfo(upFolder)
End Sub

..............

Found that if the folder "media2" has already been created, the program ran
fine and I'm able to upload files to that directory. However; if the
folder "media2" is non existent, the program will end with an error without
creating the new folder. In the final version of the program we
definitely need it be able to create various folders with different names.
The error message is:

Could not find a part of the path 'c:\inetpub\wwwroot\test\media2'.
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.IO.DirectoryNotFoundException: Could not find a
part of the path 'c:\inetpub\wwwroot\test\media2'

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path
'c:\inetpub\wwwroot\test\media2'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
+2014368
System.IO.Directory.InternalGetFileDirectoryNames( String path, String
userPathOriginal, String searchPattern, Boolean includeFiles, Boolean
includeDirs, SearchOption searchOption) +1817
System.IO.DirectoryInfo.GetFiles(String searchPattern, SearchOption
searchOption) +57
System.IO.DirectoryInfo.GetFiles() +11
ASP.ch4_aspx.Page_PreRender() +72
System.Web.Util.CalliHelper.ArglessFunctionCaller( IntPtr fp, Object o) +5
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
EventArgs e) +784015
System.Web.UI.Control.OnPreRender(EventArgs e) +2069340
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360


Am using XP pro and VS 2005; and everything resides in my own workstation.
I've already grant the ASPNET user Write permission to the
c:\inetpub\wwwroot\test folder. Any insight very much appreciated.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? guercheLE@gmail.com Digital Photography 1 10-04-2005 07:15 PM
Error: Could not find a part of the path jessica ASP .Net 0 05-20-2004 04:16 AM
Error: Could not find a part of the path / Reading and Writing to files in ASP.Net TC ASP .Net 3 05-19-2004 12:00 AM
Find the server part of the url, and the virtual root folder NWx ASP .Net 2 02-17-2004 10:50 PM
"Could not find a part of the path" error dsh ASP .Net 0 01-15-2004 09:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57