The process cannot access the file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • john20
    New Member
    • Jul 2008
    • 37

    The process cannot access the file

    Hi All,

    I have deployed the application on the windows 2003 and its domain controller, and i m accessing the application
    from client machine which has access to all the resources on the server.

    in the code i am trying to write data in .csv file but i m getting this error.


    Exception: System.IO.IOExc eption:
    The process cannot access the file 'D:\MMLIVFILTRE _080717_132556. CSV' because it is being used by another process.

    i am closing and deposing the object.

    its works fine on my development machine.

    is anyone had the same problem before. can you tell me what is the problem.

    Thanks

    -joseph
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Grab yourself a copy of Process Explorer (free from microsoft technet) and run it and go to Find->"Find Handle..." and put in that file name.
    That will show you who has the file open.

    Comment

    • john20
      New Member
      • Jul 2008
      • 37

      #3
      Hi Thanks for ur reply..

      I did the same as but it is not helping.

      some more information :

      on the server in the web.config <identity Impersonation=" True" >

      when i run from the server it works fine but when i try to access the application from user machine then it is giving the above error.

      for testing i have given the full control to the user.

      is this a permission issue ?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        What identity are you impersonating?
        Actually I suspect that when you test it and it "works fine", it's keeping the file open. So when the next user tries to to use the file its locked and they can't access it.

        Comment

        • john20
          New Member
          • Jul 2008
          • 37

          #5
          Originally posted by Plater
          What identity are you impersonating?
          Actually I suspect that when you test it and it "works fine", it's keeping the file open. So hwne the next user tries to to use the file its locked and they can't access it.
          on winodws 2003 server i am impersonating the user which is created on the domain.

          like :
          <identity impersonate="tr ue" userName ="ABC\john" password ="*****"/>

          and everytime i am creating the new file.

          below is the code:

          Code:
          Dim objSW As StreamWriter = New StreamWriter(sExportFolder & "\" & sSession & ".CSV")
          
          objSW.WriteLine(fi.DirectoryName & sColSep & fi.Name & sColSep & fi.Length & sColSep & fi.Extension.Replace(".", "") & sColSep & "144" & sColSep & Format(fi.CreationTime, "dd/MM/yyyy") & sColSep & Format(fi.LastWriteTime, "dd/MM/yyyy") & sColSep & Format(fi.LastAccessTime, "dd/MM/yyyy") & sColSep & sFIOwner)
          
          
                         objSW.Close()
                          objSW.Dispose()
                          objSW = Nothing
          closing and deposing the object after writing to the file.

          Thanks
          john

          Comment

          Working...