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 261497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:26:13+00:00 2026-05-11T22:26:13+00:00

I have an update program that is completely independent of my main application. I

  • 0

I have an update program that is completely independent of my main application. I run the update.exe to update the app.exe. To check to see if the file is in use, I move it to another file and catch an error if it is in use. If no problems occurr I rename it back. At least that was my plan…

Main program: app.exe
Update program: update.exe

This program is used over the network without any services running. So, the users is quite literally running the exe over the network on thier machine.

I need to update the app.exe when the update.exe has run. To check to see if the app.exe was still in use I was wrapping the following in a try/catch to see if it failed:

IO.File.Move(upddir & “\app.exe”, upddir & “\app.exe.tst”)
IO.File.Move(upddir & “\app.exe.tst”, upddir & “\app.exe”)

The funny thing is, even if the app.exe is running, the move can rename it to the app.exe.tst without any error. I can even continue on in the application without any errors.

I thought I was out of my mind, so I had another programmer look at this and he verified what I said above.

So, we tried this wrapped in a try catch:

Dim readfile As New FileStream(upddir & “\app.exe”, FileMode.Open, FileAccess.Read, FileShare.None)
readfile.Dispose()

I put the fileshare as none that, at least I thought it would, show that there was someone in the file.

It still continued without any error.

Anyone know why I can rename a file in use?
Also, is there a better way to do this than what I am doing now?

Thanks!
Eroc

  • 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-11T22:26:13+00:00Added an answer on May 11, 2026 at 10:26 pm

    You could do the following to check if the application has other instances running:

    Process.GetProcessesByName("app.exe", "Machine1").Length > 0
    

    Which is a more appropriate way of checking if the app is running.

    Have a look at File.Move MSDN documentation. It details what exceptions are thrown. You are allowed to rename an exe even if it is in Use in Vista.

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

Sidebar

Related Questions

I have update panel that content check box, textbox, 3 DropDownList with CascadingDropDown extender.
I use oracle 10. I have update statement like that : update table1 t1
I have a 'server' program that updates many linked lists in shared memory in
I have a Win32 C++ program that validates user input and updates the UI
I have a SQL update statement I am running from inside a PHP program.
I have a .NET Compact Framework app that can runs on three windows machines
I have an program that gets installed via an msi. The msi was built
i have a program that takes some time creating pdf files i would like
I have an older ncurses-based program that does some simple IO on a few
Lets say I have a chat program that every time someone sends a message,

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.