I am trying to write code to allow my users to upload a file. The code I am
using is as follows:
Dim upfilename As String = ""
If fileDetails.Val ue <> "" AndAlso fileDetails.Pos tedFile.Content Length > 0
Then
Dim dir As String() =
fileDetails.Pos tedFile.FileNam e.Split("\".ToC harArray())
upfilename = dir(dir.GetUppe rBound(0))
fileDetails.Pos tedFile.SaveAs( Server.MapPath( "/eventdetails/") & upfilename)
End If
When I run this code, I recieve an error similar to the following:
Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------
Could not find a part of the path "D:\Webdev_Site \eventdetails\r esume.pdf".
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.Direc toryNotFoundExc eption: Could not find a
part of the path "D:\Webdev_Site \eventdetails\r esume.pdf".
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.
Stack Trace:
[DirectoryNotFou ndException: Could not find a part of the path
"D:\Webdev_Site \eventdetails\r esume.pdf".]
System.IO.__Err or.WinIOError(I nt32 errorCode, String str) +287
System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileS tream..ctor(Str ing path, FileMode mode) +52
System.Web.Http PostedFile.Save As(String filename) +48
createevent.btn Submit_Click(Ob ject sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebC ache\https://www.webdevlccc.com\lvbeporgt...nt.aspx.vb:114
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.2300; ASP.NET
Version:1.1.432 2.2300
I have used this same code before without any problems, what do I need to do
differently?
--
Nathan Sokalski
njsokalski@hotm ail.com
using is as follows:
Dim upfilename As String = ""
If fileDetails.Val ue <> "" AndAlso fileDetails.Pos tedFile.Content Length > 0
Then
Dim dir As String() =
fileDetails.Pos tedFile.FileNam e.Split("\".ToC harArray())
upfilename = dir(dir.GetUppe rBound(0))
fileDetails.Pos tedFile.SaveAs( Server.MapPath( "/eventdetails/") & upfilename)
End If
When I run this code, I recieve an error similar to the following:
Server Error in '/lvbeporgtest' Application.
--------------------------------------------------------------------------------
Could not find a part of the path "D:\Webdev_Site \eventdetails\r esume.pdf".
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.Direc toryNotFoundExc eption: Could not find a
part of the path "D:\Webdev_Site \eventdetails\r esume.pdf".
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.
Stack Trace:
[DirectoryNotFou ndException: Could not find a part of the path
"D:\Webdev_Site \eventdetails\r esume.pdf".]
System.IO.__Err or.WinIOError(I nt32 errorCode, String str) +287
System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileS tream..ctor(Str ing path, FileMode mode) +52
System.Web.Http PostedFile.Save As(String filename) +48
createevent.btn Submit_Click(Ob ject sender, EventArgs e) in C:\Documents
and Settings\Nathan
Sokalski\VSWebC ache\https://www.webdevlccc.com\lvbeporgt...nt.aspx.vb:114
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.2300; ASP.NET
Version:1.1.432 2.2300
I have used this same code before without any problems, what do I need to do
differently?
--
Nathan Sokalski
njsokalski@hotm ail.com
Comment