System.IO.DirectoryNotFoundException: Could not find a part of the path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthias Ludwig

    System.IO.DirectoryNotFoundException: Could not find a part of the path

    I'm trying to create a directory on the web server with a
    vb.net code:
    ....

    Dim dirName As String = "w:\filepath\im ages"

    If Not Directory.Exist s(dirName) Then
    Directory.Creat eDirectory(dirN ame)
    Label1.Text = "Directory created"
    Else
    Label1.Text = "Directory exists"
    End If

    ....

    And I'm getting an exception:
    Could not find a part of the path "w:\".

    Exception Details: System.IO.Direc toryNotFoundExc eption:
    Could not find a part of the path "w:\".

    When I run it with "w:\filepat h\" it says "Directory
    exists". Only when I want to create a new directory the
    exception occurs. The ASP.NET user has all rights on that
    drive, and there would be another exception
    like ... "access to path denied".

    Does anyone knows what is going on here and what does it
    mean "could not find a part of the path"?

    I can run this code locally and it works fine, the problem
    is only at my webservers host computer.

    Regards
    Matthias

    ps here the full exception:
    Could not find a part of the path "w:\".
    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 "w:\".

    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 "w:\".]
    System.IO.__Err or.WinIOError(I nt32 errorCode, String
    str) +287
    System.IO.Direc tory.InternalCr eateDirectory(S tring
    fullPath, String path) +489
    System.IO.Direc tory.CreateDire ctory(String path) +195
    config.test.But ton1_Click(Obje ct sender, EventArgs e)
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
    +108

    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEve
    ntHandler.Raise PostBackEvent(S tring eventArgument) +57
    System.Web.UI.P age.RaisePostBa ckEvent
    (IPostBackEvent Handler sourceControl, String
    eventArgument) +18
    System.Web.UI.P age.RaisePostBa ckEvent
    (NameValueColle ction postData) +33
    System.Web.UI.P age.ProcessRequ estMain() +1277




    -----------------------------------------------------------
    ---------------------
    Version Information: Microsoft .NET Framework
    Version:1.1.432 2.573; ASP.NET Version:1.1.432 2.573




  • Matthias Ludwig

    #2
    System.IO.Direc toryNotFoundExc eption: Could not find a part of the path

    Problem solved: In the security for the w: directory, the
    ASP.NET user needs Read permission.



    [color=blue]
    >-----Original Message-----
    >I'm trying to create a directory on the web server with[/color]
    a[color=blue]
    >vb.net code:
    >....
    >
    > Dim dirName As String = "w:\filepath\im ages"
    >
    > If Not Directory.Exist s(dirName) Then
    > Directory.Creat eDirectory(dirN ame)
    > Label1.Text = "Directory created"
    > Else
    > Label1.Text = "Directory exists"
    > End If
    >
    >....
    >
    >And I'm getting an exception:
    >Could not find a part of the path "w:\".
    >
    >Exception Details: System.IO.Direc toryNotFoundExc eption:
    >Could not find a part of the path "w:\".
    >
    >When I run it with "w:\filepat h\" it says "Directory
    >exists". Only when I want to create a new directory the
    >exception occurs. The ASP.NET user has all rights on that
    >drive, and there would be another exception
    >like ... "access to path denied".
    >
    >Does anyone knows what is going on here and what does it
    >mean "could not find a part of the path"?
    >
    >I can run this code locally and it works fine, the[/color]
    problem[color=blue]
    >is only at my webservers host computer.
    >
    >Regards
    >Matthias
    >
    >ps here the full exception:
    >Could not find a part of the path "w:\".
    >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[/color]
    where[color=blue]
    >it originated in the code.
    >
    >Exception Details: System.IO.Direc toryNotFoundExc eption:
    >Could not find a part of the path "w:\".
    >
    >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 "w:\".]
    > System.IO.__Err or.WinIOError(I nt32 errorCode, String
    >str) +287
    > System.IO.Direc tory.InternalCr eateDirectory(S tring
    >fullPath, String path) +489
    > System.IO.Direc tory.CreateDire ctory(String path) +195
    > config.test.But ton1_Click(Obje ct sender, EventArgs e)
    > System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
    >+108
    >
    >System.Web.UI. WebControls.But ton.System.Web. UI.IPostBackEv[/color]
    e[color=blue]
    >ntHandler.Rais ePostBackEvent( String eventArgument) +57
    > System.Web.UI.P age.RaisePostBa ckEvent
    >(IPostBackEven tHandler sourceControl, String
    >eventArgumen t) +18
    > System.Web.UI.P age.RaisePostBa ckEvent
    >(NameValueColl ection postData) +33
    > System.Web.UI.P age.ProcessRequ estMain() +1277
    >
    >
    >
    >
    >----------------------------------------------------------[/color]
    -[color=blue]
    >---------------------
    >Version Information: Microsoft .NET Framework
    >Version:1.1.43 22.573; ASP.NET Version:1.1.432 2.573
    >
    >
    >
    >
    >.
    >[/color]

    Comment

    Working...