Can't write to folder

Discussion in 'ASP .Net' started by Reggie, Oct 18, 2008.

  1. Reggie

    Reggie Guest

    Hi And TIA. Running VS2005 and IIS7.0. I have a procedure that copies a
    file to a folder in my web application. When I run the project from VS it
    runs fine . I'm usin IE as default viewer. But when I type it directly into
    IE (http://localhost/Menu.aspx) it bombs when I try to open the connection
    cause the file doesn't get copied to the folder. Any thoughts/advice is
    appreciated.

    Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" & strFile)
    & ";" & _
    "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""

    ' create your excel connection object using the connection string
    Dim objXConn As New OleDbConnection(xConnStr)
    objXConn.Open()


    --

    Reggie
    Reggie, Oct 18, 2008
    #1
    1. Advertising

  2. On Oct 18, 11:02 am, "Reggie" <> wrote:
    > Hi And TIA.  Running VS2005 and IIS7.0.  I have a procedure that copies a
    > file to a folder in my web application.  When I run the project from VS it
    > runs fine . I'm usin IE as default viewer.  But when I type it directly into
    > IE (http://localhost/Menu.aspx) it bombs when I try to open the connection
    > cause the file doesn't get copied to the folder.  Any thoughts/advice is
    > appreciated.
    >
    >         Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    >         & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" & strFile)
    > & ";" & _
    >         "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >
    >         ' create your excel connection object using the connection string
    >         Dim objXConn As New OleDbConnection(xConnStr)
    >         objXConn.Open()
    >
    > --
    >
    > Reggie


    When you run your code within VS you run it under your own user
    account and this works. IIS uses a built-in group named IIS_IUSRS
    (IUSR account) and it seems that this account has no rights on the
    destination folder. Give to the IIS_USRS the write access to the
    folder you want them to be able to write to. This can be done by
    navigating to your folder in Windows Explorer, right-clicking on the
    folder and selecting the Security Tab.
    Alexey Smirnov, Oct 18, 2008
    #2
    1. Advertising

  3. Reggie

    Reggie Guest

    IIS_IUSRS has all the permissions to write to the folder. Also, Network
    Services and many others I have given full rights to (only to try and get it
    to work), Nothing has worked yet. I'll keep trying.

    --

    Reggie
    "Alexey Smirnov" <> wrote in message
    news:...
    On Oct 18, 11:02 am, "Reggie" <> wrote:
    > Hi And TIA. Running VS2005 and IIS7.0. I have a procedure that copies a
    > file to a folder in my web application. When I run the project from VS it
    > runs fine . I'm usin IE as default viewer. But when I type it directly
    > into
    > IE (http://localhost/Menu.aspx) it bombs when I try to open the connection
    > cause the file doesn't get copied to the folder. Any thoughts/advice is
    > appreciated.
    >
    > Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    > & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" & strFile)
    > & ";" & _
    > "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >
    > ' create your excel connection object using the connection string
    > Dim objXConn As New OleDbConnection(xConnStr)
    > objXConn.Open()
    >
    > --
    >
    > Reggie


    When you run your code within VS you run it under your own user
    account and this works. IIS uses a built-in group named IIS_IUSRS
    (IUSR account) and it seems that this account has no rights on the
    destination folder. Give to the IIS_USRS the write access to the
    folder you want them to be able to write to. This can be done by
    navigating to your folder in Windows Explorer, right-clicking on the
    folder and selecting the Security Tab.
    Reggie, Oct 18, 2008
    #3
  4. On Oct 18, 10:26 pm, "Reggie" <> wrote:
    > IIS_IUSRS has all the permissions to write to the folder.  Also, Network
    > Services and many others I have given full rights to (only to try and get it
    > to work),  Nothing has worked yet.  I'll keep trying.
    >



    Maybe there is another problem then. Did you get an error about
    insufficient write permissions, or the code is not working as
    expected? if the latter is the case can you post the code? I don't see
    anything what copies a file in the snippet you sent earlier

    > Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    > & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" & strFile)
    > & ";" & _
    > "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >
    > ' create your excel connection object using the connection string
    > Dim objXConn As New OleDbConnection(xConnStr)
    > objXConn.Open()
    Alexey Smirnov, Oct 19, 2008
    #4
  5. Reggie

    Reggie Guest

    Reggie
    "Alexey Smirnov" <> wrote in message
    news:...
    On Oct 18, 10:26 pm, "Reggie" <> wrote:
    > IIS_IUSRS has all the permissions to write to the folder. Also, Network
    > Services and many others I have given full rights to (only to try and get
    > it
    > to work), Nothing has worked yet. I'll keep trying.
    >



    Maybe there is another problem then. Did you get an error about
    insufficient write permissions, or the code is not working as
    expected? if the latter is the case can you post the code? I don't see
    anything what copies a file in the snippet you sent earlier

    > Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    > & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    > strFile)
    > & ";" & _
    > "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >
    > ' create your excel connection object using the connection string
    > Dim objXConn As New OleDbConnection(xConnStr)
    > objXConn.Open()


    No error message except stating that the file couldn't be found. Here's the
    code. Everything runs fine when running from local except when I try to
    copy a file to this folder.

    'Import Excel file
    If Not inpFileUpNIIN.PostedFile Is Nothing And
    inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    strFileName =
    System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    strBaseDir = Server.MapPath("/MDB_Temp/")
    Try
    inpFileUpNIIN.PostedFile.SaveAs(strBaseDir & strFileName)
    pathandfile = strBaseDir & strFileName
    Catch Exc As Exception
    Response.Write("Error: " & Exc.Message)
    Exit Sub
    End Try
    Else
    Response.Write("Please select a file to upload.")
    Exit Sub
    End If
    Reggie, Oct 20, 2008
    #5
  6. Reggie

    Reggie Guest

    "Reggie" <> wrote in message
    news:%...
    > Reggie
    > "Alexey Smirnov" <> wrote in message
    > news:...
    > On Oct 18, 10:26 pm, "Reggie" <> wrote:
    >> IIS_IUSRS has all the permissions to write to the folder. Also, Network
    >> Services and many others I have given full rights to (only to try and get
    >> it
    >> to work), Nothing has worked yet. I'll keep trying.
    >>

    >
    >
    > Maybe there is another problem then. Did you get an error about
    > insufficient write permissions, or the code is not working as
    > expected? if the latter is the case can you post the code? I don't see
    > anything what copies a file in the snippet you sent earlier
    >
    >> Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    >> & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    >> strFile)
    >> & ";" & _
    >> "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >>
    >> ' create your excel connection object using the connection string
    >> Dim objXConn As New OleDbConnection(xConnStr)
    >> objXConn.Open()

    >
    > No error message except stating that the file couldn't be found. Here's
    > the code. Everything runs fine when running from local except when I try
    > to copy a file to this folder.
    >
    > 'Import Excel file
    > If Not inpFileUpNIIN.PostedFile Is Nothing And
    > inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    > strFileName =
    > System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    > strBaseDir = Server.MapPath("/MDB_Temp/")
    > Try
    > inpFileUpNIIN.PostedFile.SaveAs(strBaseDir & strFileName)
    > pathandfile = strBaseDir & strFileName
    > Catch Exc As Exception
    > Response.Write("Error: " & Exc.Message)
    > Exit Sub
    > End Try
    > Else
    > Response.Write("Please select a file to upload.")
    > Exit Sub
    > End If


    Got it somewhat figured out, but don't know why. If I run it using VS
    server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    Could not find a part of the path
    'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'. If I us VS
    and set it to Server.MapPath("/MDB_Temp/") it runs fine but then it doesn't
    run when using the local server. I don't know why. I simply setup VS to
    run it using IIS server with Server.MapPath("/WSMDDT/MDB_Temp/") and it now
    runs except I can debug cause integrated windows authentication isn't
    enabled. I'm using forms authentication and not sure how to setup so I can
    debug.
    Reggie, Oct 20, 2008
    #6
  7. Reggie

    David Guest

    To debug without running via studio, click Tools / Attach to Process.

    Select the aspnet_wp process (hover over it first to ensure you are
    debugging the correct version. On my machine, I have 1.1 and 2.0) I also
    ensure in the attach to block that SQL Server is not selected. (Click the
    select button to remove it).

    Click Attach.

    Debug as normal.

    Personally, I prefer this way of handling it. I don't like the start button
    starting up a browser and when you click stop, the browser closing again.

    --
    Best regards,
    Dave Colliver.
    http://www.AshfieldFOCUS.com
    ~~
    http://www.FOCUSPortals.com - Local franchises available


    "Reggie" <> wrote in message
    news:...
    > "Reggie" <> wrote in message
    > news:%...
    >> Reggie
    >> "Alexey Smirnov" <> wrote in message
    >> news:...
    >> On Oct 18, 10:26 pm, "Reggie" <> wrote:
    >>> IIS_IUSRS has all the permissions to write to the folder. Also, Network
    >>> Services and many others I have given full rights to (only to try and
    >>> get it
    >>> to work), Nothing has worked yet. I'll keep trying.
    >>>

    >>
    >>
    >> Maybe there is another problem then. Did you get an error about
    >> insufficient write permissions, or the code is not working as
    >> expected? if the latter is the case can you post the code? I don't see
    >> anything what copies a file in the snippet you sent earlier
    >>
    >>> Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    >>> & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    >>> strFile)
    >>> & ";" & _
    >>> "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >>>
    >>> ' create your excel connection object using the connection
    >>> string
    >>> Dim objXConn As New OleDbConnection(xConnStr)
    >>> objXConn.Open()

    >>
    >> No error message except stating that the file couldn't be found. Here's
    >> the code. Everything runs fine when running from local except when I try
    >> to copy a file to this folder.
    >>
    >> 'Import Excel file
    >> If Not inpFileUpNIIN.PostedFile Is Nothing And
    >> inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    >> strFileName =
    >> System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    >> strBaseDir = Server.MapPath("/MDB_Temp/")
    >> Try
    >> inpFileUpNIIN.PostedFile.SaveAs(strBaseDir & strFileName)
    >> pathandfile = strBaseDir & strFileName
    >> Catch Exc As Exception
    >> Response.Write("Error: " & Exc.Message)
    >> Exit Sub
    >> End Try
    >> Else
    >> Response.Write("Please select a file to upload.")
    >> Exit Sub
    >> End If

    >
    > Got it somewhat figured out, but don't know why. If I run it using VS
    > server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    > Could not find a part of the path
    > 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'. If I us
    > VS and set it to Server.MapPath("/MDB_Temp/") it runs fine but then it
    > doesn't run when using the local server. I don't know why. I simply
    > setup VS to run it using IIS server with
    > Server.MapPath("/WSMDDT/MDB_Temp/") and it now runs except I can debug
    > cause integrated windows authentication isn't enabled. I'm using forms
    > authentication and not sure how to setup so I can debug.
    David, Oct 20, 2008
    #7
  8. Reggie

    Reggie Guest

    David Thanks for the reply. Did as you suggested but the aspnet_wp is not
    in the list.

    "David" <> wrote in message
    news:%...
    > To debug without running via studio, click Tools / Attach to Process.
    >
    > Select the aspnet_wp process (hover over it first to ensure you are
    > debugging the correct version. On my machine, I have 1.1 and 2.0) I also
    > ensure in the attach to block that SQL Server is not selected. (Click the
    > select button to remove it).
    >
    > Click Attach.
    >
    > Debug as normal.
    >
    > Personally, I prefer this way of handling it. I don't like the start
    > button starting up a browser and when you click stop, the browser closing
    > again.
    >
    > --
    > Best regards,
    > Dave Colliver.
    > http://www.AshfieldFOCUS.com
    > ~~
    > http://www.FOCUSPortals.com - Local franchises available
    >
    >
    > "Reggie" <> wrote in message
    > news:...
    >> "Reggie" <> wrote in message
    >> news:%...
    >>> Reggie
    >>> "Alexey Smirnov" <> wrote in message
    >>> news:...
    >>> On Oct 18, 10:26 pm, "Reggie" <> wrote:
    >>>> IIS_IUSRS has all the permissions to write to the folder. Also, Network
    >>>> Services and many others I have given full rights to (only to try and
    >>>> get it
    >>>> to work), Nothing has worked yet. I'll keep trying.
    >>>>
    >>>
    >>>
    >>> Maybe there is another problem then. Did you get an error about
    >>> insufficient write permissions, or the code is not working as
    >>> expected? if the latter is the case can you post the code? I don't see
    >>> anything what copies a file in the snippet you sent earlier
    >>>
    >>>> Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    >>>> & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    >>>> strFile)
    >>>> & ";" & _
    >>>> "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >>>>
    >>>> ' create your excel connection object using the connection
    >>>> string
    >>>> Dim objXConn As New OleDbConnection(xConnStr)
    >>>> objXConn.Open()
    >>>
    >>> No error message except stating that the file couldn't be found. Here's
    >>> the code. Everything runs fine when running from local except when I
    >>> try to copy a file to this folder.
    >>>
    >>> 'Import Excel file
    >>> If Not inpFileUpNIIN.PostedFile Is Nothing And
    >>> inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    >>> strFileName =
    >>> System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    >>> strBaseDir = Server.MapPath("/MDB_Temp/")
    >>> Try
    >>> inpFileUpNIIN.PostedFile.SaveAs(strBaseDir & strFileName)
    >>> pathandfile = strBaseDir & strFileName
    >>> Catch Exc As Exception
    >>> Response.Write("Error: " & Exc.Message)
    >>> Exit Sub
    >>> End Try
    >>> Else
    >>> Response.Write("Please select a file to upload.")
    >>> Exit Sub
    >>> End If

    >>
    >> Got it somewhat figured out, but don't know why. If I run it using VS
    >> server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    >> Could not find a part of the path
    >> 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'. If I us
    >> VS and set it to Server.MapPath("/MDB_Temp/") it runs fine but then it
    >> doesn't run when using the local server. I don't know why. I simply
    >> setup VS to run it using IIS server with
    >> Server.MapPath("/WSMDDT/MDB_Temp/") and it now runs except I can debug
    >> cause integrated windows authentication isn't enabled. I'm using forms
    >> authentication and not sure how to setup so I can debug.

    >
    >
    Reggie, Oct 21, 2008
    #8
  9. On Oct 20, 10:47 am, "Reggie" <> wrote:
    > "Reggie" <> wrote in message


    > Got it somewhat figured out, but don't know why.  If I run it using VS
    > server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    > Could not find a part of the path
    > 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'.


    So, what path do you get when you call Server.MapPath("/") ? What
    webserver do you use in VS (Project - Properties - Web) ?

    I think the problem is in your configuration - your site is located in
    C:\inetpub\wwwroot\WSMDDT, you call Server.MapPath("/WSMDDT/
    MDB_Temp/") which is wrong, and you get an error. To see why it is not
    working under http://localhost - remove Try..Catch..End. It should
    show an error message after that.

    Hope this helps.
    Alexey Smirnov, Oct 21, 2008
    #9
  10. Reggie

    David Guest

    If it isn't in the list when you try, then if you have not used your local
    web for a while, it will have closed itself down. Simply open a browser and
    goto your local site (ensure you call a .NET page, doesn't even need to be
    in the same project) and that will start your aspnet_wp. (On different OS,
    (vista I think) it could be called w3wp, on XP it is aspnet_wp).

    Hope this helps.

    --
    Best regards,
    Dave Colliver.
    http://www.AshfieldFOCUS.com
    ~~
    http://www.FOCUSPortals.com - Local franchises available


    "Reggie" <> wrote in message
    news:%...
    > David Thanks for the reply. Did as you suggested but the aspnet_wp is not
    > in the list.
    >
    > "David" <> wrote in message
    > news:%...
    >> To debug without running via studio, click Tools / Attach to Process.
    >>
    >> Select the aspnet_wp process (hover over it first to ensure you are
    >> debugging the correct version. On my machine, I have 1.1 and 2.0) I also
    >> ensure in the attach to block that SQL Server is not selected. (Click the
    >> select button to remove it).
    >>
    >> Click Attach.
    >>
    >> Debug as normal.
    >>
    >> Personally, I prefer this way of handling it. I don't like the start
    >> button starting up a browser and when you click stop, the browser closing
    >> again.
    >>
    >> --
    >> Best regards,
    >> Dave Colliver.
    >> http://www.AshfieldFOCUS.com
    >> ~~
    >> http://www.FOCUSPortals.com - Local franchises available
    >>
    >>
    >> "Reggie" <> wrote in message
    >> news:...
    >>> "Reggie" <> wrote in message
    >>> news:%...
    >>>> Reggie
    >>>> "Alexey Smirnov" <> wrote in message
    >>>> news:...
    >>>> On Oct 18, 10:26 pm, "Reggie" <> wrote:
    >>>>> IIS_IUSRS has all the permissions to write to the folder. Also,
    >>>>> Network
    >>>>> Services and many others I have given full rights to (only to try and
    >>>>> get it
    >>>>> to work), Nothing has worked yet. I'll keep trying.
    >>>>>
    >>>>
    >>>>
    >>>> Maybe there is another problem then. Did you get an error about
    >>>> insufficient write permissions, or the code is not working as
    >>>> expected? if the latter is the case can you post the code? I don't see
    >>>> anything what copies a file in the snippet you sent earlier
    >>>>
    >>>>> Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    >>>>> & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    >>>>> strFile)
    >>>>> & ";" & _
    >>>>> "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >>>>>
    >>>>> ' create your excel connection object using the connection
    >>>>> string
    >>>>> Dim objXConn As New OleDbConnection(xConnStr)
    >>>>> objXConn.Open()
    >>>>
    >>>> No error message except stating that the file couldn't be found.
    >>>> Here's the code. Everything runs fine when running from local except
    >>>> when I try to copy a file to this folder.
    >>>>
    >>>> 'Import Excel file
    >>>> If Not inpFileUpNIIN.PostedFile Is Nothing And
    >>>> inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    >>>> strFileName =
    >>>> System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    >>>> strBaseDir = Server.MapPath("/MDB_Temp/")
    >>>> Try
    >>>> inpFileUpNIIN.PostedFile.SaveAs(strBaseDir &
    >>>> strFileName)
    >>>> pathandfile = strBaseDir & strFileName
    >>>> Catch Exc As Exception
    >>>> Response.Write("Error: " & Exc.Message)
    >>>> Exit Sub
    >>>> End Try
    >>>> Else
    >>>> Response.Write("Please select a file to upload.")
    >>>> Exit Sub
    >>>> End If
    >>>
    >>> Got it somewhat figured out, but don't know why. If I run it using VS
    >>> server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says
    >>> it Could not find a part of the path
    >>> 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'. If I
    >>> us VS and set it to Server.MapPath("/MDB_Temp/") it runs fine but then
    >>> it doesn't run when using the local server. I don't know why. I simply
    >>> setup VS to run it using IIS server with
    >>> Server.MapPath("/WSMDDT/MDB_Temp/") and it now runs except I can debug
    >>> cause integrated windows authentication isn't enabled. I'm using forms
    >>> authentication and not sure how to setup so I can debug.

    >>
    >>

    >
    David, Oct 21, 2008
    #10
  11. Reggie

    Reggie Guest

    David, Found it. (w3wp). Thanks!

    --

    Reggie
    "David" <> wrote in message
    news:...
    > If it isn't in the list when you try, then if you have not used your local
    > web for a while, it will have closed itself down. Simply open a browser
    > and goto your local site (ensure you call a .NET page, doesn't even need
    > to be in the same project) and that will start your aspnet_wp. (On
    > different OS, (vista I think) it could be called w3wp, on XP it is
    > aspnet_wp).
    >
    > Hope this helps.
    >
    > --
    > Best regards,
    > Dave Colliver.
    > http://www.AshfieldFOCUS.com
    > ~~
    > http://www.FOCUSPortals.com - Local franchises available
    >
    >
    > "Reggie" <> wrote in message
    > news:%...
    >> David Thanks for the reply. Did as you suggested but the aspnet_wp is
    >> not in the list.
    >>
    >> "David" <> wrote in message
    >> news:%...
    >>> To debug without running via studio, click Tools / Attach to Process.
    >>>
    >>> Select the aspnet_wp process (hover over it first to ensure you are
    >>> debugging the correct version. On my machine, I have 1.1 and 2.0) I also
    >>> ensure in the attach to block that SQL Server is not selected. (Click
    >>> the select button to remove it).
    >>>
    >>> Click Attach.
    >>>
    >>> Debug as normal.
    >>>
    >>> Personally, I prefer this way of handling it. I don't like the start
    >>> button starting up a browser and when you click stop, the browser
    >>> closing again.
    >>>
    >>> --
    >>> Best regards,
    >>> Dave Colliver.
    >>> http://www.AshfieldFOCUS.com
    >>> ~~
    >>> http://www.FOCUSPortals.com - Local franchises available
    >>>
    >>>
    >>> "Reggie" <> wrote in message
    >>> news:...
    >>>> "Reggie" <> wrote in message
    >>>> news:%...
    >>>>> Reggie
    >>>>> "Alexey Smirnov" <> wrote in message
    >>>>> news:...
    >>>>> On Oct 18, 10:26 pm, "Reggie" <> wrote:
    >>>>>> IIS_IUSRS has all the permissions to write to the folder. Also,
    >>>>>> Network
    >>>>>> Services and many others I have given full rights to (only to try and
    >>>>>> get it
    >>>>>> to work), Nothing has worked yet. I'll keep trying.
    >>>>>>
    >>>>>
    >>>>>
    >>>>> Maybe there is another problem then. Did you get an error about
    >>>>> insufficient write permissions, or the code is not working as
    >>>>> expected? if the latter is the case can you post the code? I don't see
    >>>>> anything what copies a file in the snippet you sent earlier
    >>>>>
    >>>>>> Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
    >>>>>> _
    >>>>>> & "Data Source=" & Server.MapPath("WSMDDT_Old\MDB_Temp\" &
    >>>>>> strFile)
    >>>>>> & ";" & _
    >>>>>> "Extended Properties=""Excel 8.0;HDR=TRUE;IMEX=1"""
    >>>>>>
    >>>>>> ' create your excel connection object using the connection
    >>>>>> string
    >>>>>> Dim objXConn As New OleDbConnection(xConnStr)
    >>>>>> objXConn.Open()
    >>>>>
    >>>>> No error message except stating that the file couldn't be found.
    >>>>> Here's the code. Everything runs fine when running from local except
    >>>>> when I try to copy a file to this folder.
    >>>>>
    >>>>> 'Import Excel file
    >>>>> If Not inpFileUpNIIN.PostedFile Is Nothing And
    >>>>> inpFileUpNIIN.PostedFile.ContentLength > 0 Then
    >>>>> strFileName =
    >>>>> System.IO.Path.GetFileName(inpFileUpNIIN.PostedFile.FileName)
    >>>>> strBaseDir = Server.MapPath("/MDB_Temp/")
    >>>>> Try
    >>>>> inpFileUpNIIN.PostedFile.SaveAs(strBaseDir &
    >>>>> strFileName)
    >>>>> pathandfile = strBaseDir & strFileName
    >>>>> Catch Exc As Exception
    >>>>> Response.Write("Error: " & Exc.Message)
    >>>>> Exit Sub
    >>>>> End Try
    >>>>> Else
    >>>>> Response.Write("Please select a file to upload.")
    >>>>> Exit Sub
    >>>>> End If
    >>>>
    >>>> Got it somewhat figured out, but don't know why. If I run it using VS
    >>>> server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says
    >>>> it Could not find a part of the path
    >>>> 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'. If I
    >>>> us VS and set it to Server.MapPath("/MDB_Temp/") it runs fine but then
    >>>> it doesn't run when using the local server. I don't know why. I
    >>>> simply setup VS to run it using IIS server with
    >>>> Server.MapPath("/WSMDDT/MDB_Temp/") and it now runs except I can debug
    >>>> cause integrated windows authentication isn't enabled. I'm using forms
    >>>> authentication and not sure how to setup so I can debug.
    >>>
    >>>

    >>

    >
    >
    Reggie, Oct 22, 2008
    #11
  12. Reggie

    Reggie Guest

    gie
    "Alexey Smirnov" <> wrote in message
    news:...
    On Oct 20, 10:47 am, "Reggie" <> wrote:
    > "Reggie" <> wrote in message


    > Got it somewhat figured out, but don't know why. If I run it using VS
    > server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    > Could not find a part of the path
    > 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'.


    So, what path do you get when you call Server.MapPath("/") ? What
    webserver do you use in VS (Project - Properties - Web) ?

    I think the problem is in your configuration - your site is located in
    C:\inetpub\wwwroot\WSMDDT, you call Server.MapPath("/WSMDDT/
    MDB_Temp/") which is wrong, and you get an error. To see why it is not
    working under http://localhost - remove Try..Catch..End. It should
    show an error message after that.

    Hope this helps.

    Using IIS 7.0 Server
    Vista Business (SP1)
    VS2005
    ..Net 2.0 (SP1)

    Running using IIS Server

    Server.MapPath("/") returns C:\inetpub\wwwroot\
    Server.MapPath("/MDB_Temp/") returns C:\inetpub\wwwroot\MDB_Temp\
    Server.MapPath("/WSMDDT/MDB_Temp/") returns
    C:\inetpub\wwwroot\WSMDDT\MDB_Temp\

    Running using VS Server

    Server.MapPath("/") returns C:\inetpub\wwwroot\WSMDDT\
    Server.MapPath("/MDB_Temp/") returns C:\inetpub\wwwroot\WSMDDT\MDB_Temp\
    Server.MapPath("/WSMDDT/MDB_Temp/") returns
    C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\


    The last one (running using IIS Server) is what I want and it is working as
    expected. My problem was that when I originally posted my question I was
    using VS server and the Server.MapPath("/WSMDDT/MDB_Temp/") failed, however
    when I took out the WSMDDT portion so that it read
    Server.MapPath("/MDB_Temp/") It ran fine from VS, but failed when I tried to
    simply run the app from the local server. Think I'm good now cause I set it
    up to run from IIS server and all is well. Just thought it was/is odd that
    this happens. Thanks VERY much for all the help.
    --

    Reg
    Reggie, Oct 22, 2008
    #12
  13. On Oct 22, 2:34 am, "Reggie" <> wrote:
    > gie"Alexey Smirnov" <> wrote in message
    >
    > news:...
    > On Oct 20, 10:47 am, "Reggie" <> wrote:
    >
    > > "Reggie" <> wrote in message
    > > Got it somewhat figured out, but don't know why. If I run it using VS
    > > server and use the setting Server.MapPath("/WSMDDT/MDB_Temp/") it says it
    > > Could not find a part of the path
    > > 'C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\ExcelImport_rep.xls'.

    >
    > So, what path do you get when you call Server.MapPath("/") ? What
    > webserver do you use in VS (Project - Properties - Web) ?
    >
    > I think the problem is in your configuration - your site is located in
    > C:\inetpub\wwwroot\WSMDDT, you call Server.MapPath("/WSMDDT/
    > MDB_Temp/") which is wrong, and you get an error. To see why it is not
    > working underhttp://localhost- remove Try..Catch..End. It should
    > show an error message after that.
    >
    > Hope this helps.
    >
    > Using IIS 7.0 Server
    > Vista Business (SP1)
    > VS2005
    > .Net 2.0 (SP1)
    >
    > Running using IIS Server
    >
    > Server.MapPath("/")  returns C:\inetpub\wwwroot\
    > Server.MapPath("/MDB_Temp/")  returns C:\inetpub\wwwroot\MDB_Temp\
    > Server.MapPath("/WSMDDT/MDB_Temp/")  returns
    > C:\inetpub\wwwroot\WSMDDT\MDB_Temp\
    >
    > Running using VS Server
    >
    > Server.MapPath("/")  returns C:\inetpub\wwwroot\WSMDDT\
    > Server.MapPath("/MDB_Temp/")  returns C:\inetpub\wwwroot\WSMDDT\MDB_Temp\
    > Server.MapPath("/WSMDDT/MDB_Temp/")  returns
    > C:\inetpub\wwwroot\WSMDDT\WSMDDT\MDB_Temp\
    >
    > The last one (running using IIS Server) is what I want and it is working as
    > expected.  My problem was that when I originally posted my question I was
    > using VS server and the Server.MapPath("/WSMDDT/MDB_Temp/") failed, however
    > when I took out the WSMDDT portion so that it read
    > Server.MapPath("/MDB_Temp/") It ran fine from VS, but failed when I tried to
    > simply run the app from the local server.  Think I'm good now cause I set it
    > up to run from IIS server and all is well.  Just thought it was/is odd that
    > this happens.  Thanks VERY much for all the help.
    > --
    >
    > Reg


    Great that it works for you now. Cheers!
    Alexey Smirnov, Oct 22, 2008
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,902
    Alvin Bruney
    Oct 16, 2003
  2. William LaMartin

    _vti_cnf folder in the bin folder-- a problem?

    William LaMartin, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,678
    Oliver
    Nov 10, 2003
  3. could ildg
    Replies:
    0
    Views:
    455
    could ildg
    Jul 1, 2005
  4. Jeff Epler
    Replies:
    0
    Views:
    391
    Jeff Epler
    Jul 1, 2005
  5. could ildg
    Replies:
    0
    Views:
    490
    could ildg
    Jul 2, 2005
Loading...

Share This Page