Could not find file Error

Discussion in 'ASP .Net' started by Amritha.Datta@gmail.com, Jul 23, 2007.

  1. Guest

    Can anyone tell me why the below code returns error?
    Exception Details: System.IO.FileNotFoundException: Could not find
    file

    Dim strLFolder As String = "c:\Temp\F Files"
    Dim intClientID As Integer = 1221

    Dim XMLStr As String = strLFolder & "\" &
    intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
    Dim dsPubs As New DataSet
    dsPubs.ReadXml(XMLStr)

    where as the below code is working

    Dim dsPubs As New DataSet
    dsPubs.ReadXml("c:\temp\F Files\1221\Lk
    \HeaderTrailerDeltails_data.xml")


    Thanks
    , Jul 23, 2007
    #1
    1. Advertising

  2. Patrice Guest

    Is Deltails in both intentional ?

    My approach would be to read the directory content using DirectoryInfo and
    do a char by char comparison to get the first mismatch char so that this is
    my computer that works to find the difference (for example you could have a
    non secable white space character that would be near impossible to find by
    just looking).

    --
    Patrice

    <> a écrit dans le message de news:
    ...
    > Can anyone tell me why the below code returns error?
    > Exception Details: System.IO.FileNotFoundException: Could not find
    > file
    >
    > Dim strLFolder As String = "c:\Temp\F Files"
    > Dim intClientID As Integer = 1221
    >
    > Dim XMLStr As String = strLFolder & "\" &
    > intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
    > Dim dsPubs As New DataSet
    > dsPubs.ReadXml(XMLStr)
    >
    > where as the below code is working
    >
    > Dim dsPubs As New DataSet
    > dsPubs.ReadXml("c:\temp\F Files\1221\Lk
    > \HeaderTrailerDeltails_data.xml")
    >
    >
    > Thanks
    >
    Patrice, Jul 23, 2007
    #2
    1. Advertising

  3. Guest

    On Jul 23, 1:41 pm, "Patrice" <http://www.chez.com/scribe/> wrote:
    > Is Deltails in both intentional ?
    >
    > My approach would be to read the directory content using DirectoryInfo and
    > do a char by char comparison to get the first mismatch char so that this is
    > my computer that works to find the difference (for example you could have a
    > non secable white space character that would be near impossible to find by
    > just looking).
    >
    > --
    > Patrice
    >
    > <> a écrit dans le message de news:
    > ...
    >
    > > Can anyone tell me why the below code returns error?
    > > Exception Details: System.IO.FileNotFoundException: Could not find
    > > file

    >
    > > Dim strLFolder As String = "c:\Temp\F Files"
    > > Dim intClientID As Integer = 1221

    >
    > > Dim XMLStr As String = strLFolder & "\" &
    > > intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
    > > Dim dsPubs As New DataSet
    > > dsPubs.ReadXml(XMLStr)

    >
    > > where as the below code is working

    >
    > > Dim dsPubs As New DataSet
    > > dsPubs.ReadXml("c:\temp\F Files\1221\Lk
    > > \HeaderTrailerDeltails_data.xml")

    >
    > > Thanks


    The directory is valid and existing in the hard disk.
    The problem is why it is throwing error if I use the first method?

    I will have to use the first method because that enable me to get
    different clientID values dynamically in the program.

    Thanks
    , Jul 23, 2007
    #3
  4. Patrice Guest

    I don't see any obvious reason but my first assumption would be that this is
    for some legitimate reason. So once again I would code a file name
    comparision to make sure that there is no mismatch in particular regarding
    white spaces that are almost uncheckable by just looking at them. Have you
    tried what I have suggested ?

    Also what if you try both code you submitted but using a single variable
    that contains the file name (this way you are 100% sure that both file name
    are the same) ?

    Etc....
    --
    Patrice

    <> a écrit dans le message de news:
    ...
    On Jul 23, 1:41 pm, "Patrice" <http://www.chez.com/scribe/> wrote:
    > Is Deltails in both intentional ?
    >
    > My approach would be to read the directory content using DirectoryInfo and
    > do a char by char comparison to get the first mismatch char so that this
    > is
    > my computer that works to find the difference (for example you could have
    > a
    > non secable white space character that would be near impossible to find by
    > just looking).
    >
    > --
    > Patrice
    >
    > <> a écrit dans le message de news:
    > ...
    >
    > > Can anyone tell me why the below code returns error?
    > > Exception Details: System.IO.FileNotFoundException: Could not find
    > > file

    >
    > > Dim strLFolder As String = "c:\Temp\F Files"
    > > Dim intClientID As Integer = 1221

    >
    > > Dim XMLStr As String = strLFolder & "\" &
    > > intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
    > > Dim dsPubs As New DataSet
    > > dsPubs.ReadXml(XMLStr)

    >
    > > where as the below code is working

    >
    > > Dim dsPubs As New DataSet
    > > dsPubs.ReadXml("c:\temp\F Files\1221\Lk
    > > \HeaderTrailerDeltails_data.xml")

    >
    > > Thanks


    The directory is valid and existing in the hard disk.
    The problem is why it is throwing error if I use the first method?

    I will have to use the first method because that enable me to get
    different clientID values dynamically in the program.

    Thanks
    Patrice, Jul 24, 2007
    #4
  5. I bet your problem is with permissions.
    You may need to adjust the security on that folder to allow the ASPNET (or
    NetworkService) user the necessary permissions.
    Alternately you could use impersonation to have ASP.NET run under a
    different user account:
    <!-- Web.config file. -->
    <identity impersonate="true" userName="Redmond\BillG" password="Melinda"/>

    --
    I hope this helps,
    Steve C. Orr,
    MCSD, MVP, CSM, ASPInsider
    http://SteveOrr.net


    <> wrote in message
    news:...
    > Can anyone tell me why the below code returns error?
    > Exception Details: System.IO.FileNotFoundException: Could not find
    > file
    >
    > Dim strLFolder As String = "c:\Temp\F Files"
    > Dim intClientID As Integer = 1221
    >
    > Dim XMLStr As String = strLFolder & "\" &
    > intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
    > Dim dsPubs As New DataSet
    > dsPubs.ReadXml(XMLStr)
    >
    > where as the below code is working
    >
    > Dim dsPubs As New DataSet
    > dsPubs.ReadXml("c:\temp\F Files\1221\Lk
    > \HeaderTrailerDeltails_data.xml")
    >
    >
    > Thanks
    >
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Jul 25, 2007
    #5
    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. chandan
    Replies:
    2
    Views:
    786
    chandan
    Mar 12, 2008
  2. Jerry C
    Replies:
    4
    Views:
    2,286
    Thomas Sun [MSFT]
    Jan 13, 2010
  3. chandan
    Replies:
    0
    Views:
    750
    chandan
    Mar 11, 2008
  4. E. Kwong
    Replies:
    0
    Views:
    290
    E. Kwong
    Nov 6, 2006
  5. Could not find file Error

    , Jul 23, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    112
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Jul 25, 2007
Loading...

Share This Page