Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 922303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:00:27+00:00 2026-05-15T19:00:27+00:00

I using C# .NET , vs 2008 , .net 3.5 For me, is difficult,

  • 0

I using C# .NET , vs 2008 , .net 3.5

For me, is difficult, but I need sample code in C# for this:

  1. How get the error code of IOException “The process cannot access the file ‘XYZ’ because it is being used by another process.”

For example, in my issue.

I try delete file, and I get “The process cannot access the file ‘XYZ’ because it is being used by another process.” Exception.

try
{
    File.Delete(infoFichero.Ruta);
}
catch (IOException ex)
{
    // ex.Message == "The process cannot access the file 'XYZ' because it is being used by another process."
}

But if .NET is Spanish, I get “El proceso no puede obtener acceso al archivo ‘00000004.PDF’ porque está siendo utilizado en otro proceso” message.

System.IO.IOException: El proceso no puede obtener acceso al archivo '00000004.PDF' porque está siendo utilizado en otro proceso.
   en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   en System.IO.FileInfo.Delete()

I need a ERROR CODE for that Exception. In Trace, I have seen System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

How get the error code of IOException “The process cannot access the file ‘XYZ’ because it is being used by another process.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:00:28+00:00Added an answer on May 15, 2026 at 7:00 pm

    You might have noticed that the HResult property is not accessible. The workaround is to use the Marshal.GetLastWin32Error() method to get the native Windows error code. Like this:

            catch (IOException ex) {
                int err = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                if (err == 32) Console.WriteLine("It's locked");
                // etc..
            }
    

    Error code 32 is named ERROR_SHARING_VIOLATION in the SDK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net C# 2008, and I need to create a search textbox
I using C# .NET , vs 2008 , .net 3.5 For me, is difficult,
I'm using vb.net 2008 and DataGridView. I'm looking for code that will allow me
i am using asp.net 2008 and i have implemented the in-build Gridview Paging.But it
I have a procedure in VB.net using VS.net 2008 which will get the list
I'm currecntly developping a sample orders management solution using VB.NET 2008, NHibernate, FluentNHibernate and
OK, this is a minor issue... but still irritating nonetheless. In MSVS 2008 .NET
Using vb.net 2008. I am trying to use TransactionScope but when I put Imports
Using vb.net 2008 I want to display a table in the form, so i
I am designing a shared add-in using VB.Net 2008 and VSTO that has to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.