Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. The process cannot access the file '' because it is being used by another process

The process cannot access the file '' because it is being used by another process

Scheduled Pinned Locked Moved C#
csharphelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3963475
    wrote on last edited by
    #1

    Hi all, I am using windows application in C#. Sometimes i am getting the below exception, {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} [System.IO.IOException]: {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: null Message: "The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process." Source: "IHSPublisher" StackTrace: " at IHSPublisher.Publisher.p_GetDocumentByFileIdentifierCompleted(Object sender, GetDocumentByFileIdentifierCompletedEventArgs e) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Publisher.cs:line 319\r\n at IHSPublisher.PCNAlert.Service.Publishing.Publisher.OnGetDocumentByFileIdentifierOperationCompleted(Object arg) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Web References\\PCNAlert.Service.Publishing\\Reference.cs:line 486" TargetSite: {Void p_GetDocumentByFileIdentifierCompleted(System.Object, IHSPublisher.PCNAlert.Service.Publishing.GetDocumentByFileIdentifierCompletedEventArgs)} Can anyone help me to solve this exception. Thanks, Ashok

    M U 2 Replies Last reply
    0
    • U User 3963475

      Hi all, I am using windows application in C#. Sometimes i am getting the below exception, {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} [System.IO.IOException]: {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: null Message: "The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process." Source: "IHSPublisher" StackTrace: " at IHSPublisher.Publisher.p_GetDocumentByFileIdentifierCompleted(Object sender, GetDocumentByFileIdentifierCompletedEventArgs e) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Publisher.cs:line 319\r\n at IHSPublisher.PCNAlert.Service.Publishing.Publisher.OnGetDocumentByFileIdentifierOperationCompleted(Object arg) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Web References\\PCNAlert.Service.Publishing\\Reference.cs:line 486" TargetSite: {Void p_GetDocumentByFileIdentifierCompleted(System.Object, IHSPublisher.PCNAlert.Service.Publishing.GetDocumentByFileIdentifierCompletedEventArgs)} Can anyone help me to solve this exception. Thanks, Ashok

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      So presumably another process is writing the file to the location, I am assuming you are trying to read it while some other process is still writing. Build in a delay for x seconds the first time you see the file and try again.

      Never underestimate the power of human stupidity RAH

      T 1 Reply Last reply
      0
      • M Mycroft Holmes

        So presumably another process is writing the file to the location, I am assuming you are trying to read it while some other process is still writing. Build in a delay for x seconds the first time you see the file and try again.

        Never underestimate the power of human stupidity RAH

        T Offline
        T Offline
        ToolMaker2007
        wrote on last edited by
        #3

        Hi, I get the same error. I'm using a FileInfo object with a file name passed to the constructor upon creating the FileInfo object. I check if the file exist and if so I delete it and recreat it. Al works fine first time but when I click on the button again to do the same functionality over again I get same error mentioned. The is NO close method on the FileInfo object nor Dispose. I tried the Refresh() in desprate attemps but still error. Please see a snipplet below: private void button2_Click(object sender, EventArgs e) { FileInfo fileInfo = new FileInfo(label2.Text + ".TMP"); if (fileInfo.Exists) { fileInfo.Delete(); } fileInfo.Create(); int y = 0; }

        T 1 Reply Last reply
        0
        • T ToolMaker2007

          Hi, I get the same error. I'm using a FileInfo object with a file name passed to the constructor upon creating the FileInfo object. I check if the file exist and if so I delete it and recreat it. Al works fine first time but when I click on the button again to do the same functionality over again I get same error mentioned. The is NO close method on the FileInfo object nor Dispose. I tried the Refresh() in desprate attemps but still error. Please see a snipplet below: private void button2_Click(object sender, EventArgs e) { FileInfo fileInfo = new FileInfo(label2.Text + ".TMP"); if (fileInfo.Exists) { fileInfo.Delete(); } fileInfo.Create(); int y = 0; }

          T Offline
          T Offline
          ToolMaker2007
          wrote on last edited by
          #4

          Hi Guys, Mine was a dumbass developer faullt...well... din't realy knew once you create the file the creat method returns a stream :laugh: so yea just changed my line of code abit FileStream stream = fileInfo.Create(); stream.Close() Hope your problem is as simple as this...

          1 Reply Last reply
          0
          • U User 3963475

            Hi all, I am using windows application in C#. Sometimes i am getting the below exception, {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} [System.IO.IOException]: {"The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: null Message: "The process cannot access the file 'C:\\Documents and Settings\\suq31399\\Local Settings\\Temp\\IHSPublisher\\d954cc77-2722-41c3-9efa-3b20e11003cf.txt' because it is being used by another process." Source: "IHSPublisher" StackTrace: " at IHSPublisher.Publisher.p_GetDocumentByFileIdentifierCompleted(Object sender, GetDocumentByFileIdentifierCompletedEventArgs e) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Publisher.cs:line 319\r\n at IHSPublisher.PCNAlert.Service.Publishing.Publisher.OnGetDocumentByFileIdentifierOperationCompleted(Object arg) in D:\\Ashok\\Projects\\PCN2.3\\newpublisher_080808\\IHSPublisher\\Web References\\PCNAlert.Service.Publishing\\Reference.cs:line 486" TargetSite: {Void p_GetDocumentByFileIdentifierCompleted(System.Object, IHSPublisher.PCNAlert.Service.Publishing.GetDocumentByFileIdentifierCompletedEventArgs)} Can anyone help me to solve this exception. Thanks, Ashok

            U Offline
            U Offline
            User 3349388
            wrote on last edited by
            #5

            string FilePath = "C:\\Users\\VijayaShyam\\Documents\\Visual Studio 2008\\Projects\\UdayPowerSystems\\UdayPowerSystems\\PrintPage.txt"; System.Security.AccessControl.FileSecurity FS = new System.Security.AccessControl.FileSecurity("PrintFile.txt",System.Security.AccessControl.AccessControlSections.Access); // string temp = "D:"; //System.IO.Path.GetTempPath(); FileStream fStream = File.Open(FilePath,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.ReadWrite); fStream.SetAccessControl(FS); // System.Security.AccessControl.DirectorySecurity dSec = Directory.GetAccessControl(fStream.Name); fStream.GetAccessControl(); /// Which OS Your using

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups