Refresh the Windows OS from within Visual Basic

  • Thread starter Thread starter Robert Mileski
  • Start date Start date
R

Robert Mileski

I've made some program in Visual Basic 2005 that works with changing files
and folders. After I've finished it, the main problem is to refresh the
Windows OS. I mean the same thing as when we press F5. Than everything
refreshes and if we have made changes, they are immediately shown.

Could someone help me with this matter? A possible solution or maybe an idea
how to do that?

Suppose that you see in front of you the Windows XP Desktop and you press F5
or from the menu with mouse right click you choose Refresh. That refreshes
the screen. Or in Explorer the same happens. THAT is what I want to do. Not
reboot the computer. And, refresh is not equal to Rebooting the machine. I
don't know how you came up with this.

And about the program, for example: The program moves a file from one place,
changes its name, and then again moves the file to the same location. If you
open explorer in that folder, and you execute the above explained program,
the explorer won't show you the changed name. You must press F5 to refresh
the Explorer, in order to see that the file has been changed.

Suppose this case:

1. Open Explorer, or my computer and in C:\ open a folder named Temp

2. Create a file there named "text.txt"

3. Leave the explorer open

4. Now make a program in VB, that renames this file into for example:
"example.txt"

5. Now compile and run the program. (The filename is changed without a
problem)

6. Now go to the Explorer window, and you will still see there the file
under the name "text.txt" and not "explorer.txt".

7. Press now F5, and there it is! You see that the file is changed!

That is what I want to refresh! When I make a change on the hard disk, I
want all the active programs working with the disk (like explorer) to notice
the change, and refresh themselfs.

I suppose I should do this now through Win API. But I don't know which API
command actually does the trick.

Was my explanation better ?

ps.. And still another thing why I'm moving a file instead of renaming it.
Try this: make a program in VB that renames a file called "text.txt" into
"Text.txt" with the difference of the second file has a big letter T. Visual
basic will report Error, there is already a file named with the same name.
Operation failed! Than YOU MUST move the file, and put it back with a new
name.


Thank you,

Robert Mileski.
 
Robert said:
ps.. And still another thing why I'm moving a file instead of
renaming it. Try this: make a program in VB that renames a file
called "text.txt" into "Text.txt" with the difference of the second
file has a big letter T. Visual basic will report Error, there is
already a file named with the same name. Operation failed! Than YOU
MUST move the file, and put it back with a new name.

Why not change the name to something else and then name it to what you want?
That way there's no chance that it will end up moving the file between
disks, which would be very time-consuming compared to just renaming it
twice.

There is a function to get a unique filename, but I don't know what it is.

Andrew
 
Back
Top