Hello All,
I have 2 problems I think related to same problem
I use VB6 pro edition with SP6
The first
I use thr function RmDir to delete a directory when cancel button is clicked, it works on 98,ME but in XP I get "File Acsess error" message.
I stop the progream in design mode, use Total commander tool, I see the Folder with no marks in the property filed, Not read only nor hidden etc. I try to delete, I get unable to delet "Read Only" directory,(Normally it says IS read only delete anyway, then it deletes it), from the explorer "My computer > etc" and right click the directory, select properties, I see the read Only has a DOT not a mark. I click it, it changes to mark, then next click clears the mark, click apply, then ok, if I re open it I get the same strange Mark again. If I use right click and delete, I get "The file is in use by another application." Error message
I need to close the VB alltogether to delete this folder.
The same with "FileSystenScript". I tried to use ChDir and ChDrive before RmDir All did not help.

The Second
I made an application with MsChart in a MDI, the child form has MsChart and RTbox and MsHFlexGrid. User switch those controls with buttons to hide and show controls.
It also works fine in 98 and ME but in XP, clicking to dislay the chart, the program hangs and the computer freezes and it is too difficult to get out of it. Single step through code does NOT cause any error and it is all fine, I tried DoEvents to introduce some delays but no improvement, I think it is the same bad interface between VB6 and XP causes some functions misbehave.

If anybody has help please let me know
Thanks Very much in advance :-|

Hmn, Maybe your code post your project in a .zip, or post the code that is relevant to each problem?

Maged,

I don't know about the problems you are having with the Chart componenets but the "The file is in use by another application." Error message has been bugging me also. I have not encountrered this from within VB, becuase I have not used it, but from other programs.

What happens is that when you create the directory VB keeps a lock on the directory as long as VB is in memory.

If you are not using the scripting library I strongly suggest that you use it by adding a reference to "Microsoft Scripting Runtime" this will allow you to better control when the locks are put and released within your program.

Once you have added this reference I suggest you try the following:
- Create a fso(FileSystemObject) variable and use this to create your directory - NOT the MkDir from VB itself but rather the fso.CreateFolder(<Path>) method
- After you create the directory set your fsovariable to "Nothing" - this should release any locks it keeps on the directory structure
- Re-initialize your fsovariable and try to delete the directory now

I know that VB is supposed to handle all the lock releases itself but I never trust any programming language to do it correctly without being explicitly told to do so.

Please tell me if it works, I am curious.

Yomet

Hi Yomet

Thanks very much, your code worked. I like to say few thing that might help others too

I am sorry I forgot to say that the folder was not created by code, it was only navigated into by the commondialog That is
it is a wizard to create HTML help files for a vb project

after user opens a "save as" dialog to write a help project name, I assumed he would like to open a new directory to save all his related files away from original vb files, so I created a folder, changed its name, entered that new folder then assumed a help project file name inside
Other times, that directory was left from a previous session but navigated into by that "Save As" dialog. now if I decide to cancel at any time my program should delete that folder too, That is why I used RmDir so if the folder is not empty, an "On error resume next" would leave the directory in place.
Your Idea gave me a hint to try the API calls instead, still did not work even from a different project specially crated for that purpose , a single form with test button,
a created directory by save as dialog will be locked as long as the VB is running. even after you open and close another file, at lease you need to unload that form that called save as dialog.

What I think is a bug here is, "save as" dialog does NOT lock the file you select and "Kill FileName" works but the parent directory is locked!!!

So I had to change my code so I create the Folder with FS filesystem and assume the vb filename is the help file name with different extension and in \HLP folder code created.
Now even RmDir delete the folder...

All that did not exist in previous Windows(tm) versions

Hmn, Maybe your code post your project in a .zip, or post the code that is relevant to each problem?

I will do some homework on that code first thes post it, I got some ideas, In any case I will post the results good or bad

Thanks very much

Hi, Thanks again for support, after several attempts of trying I found that it has nothing to to with MSchart.
It is a project tracing software, I have one 2x11 MSHgrid, where user inputs project's parameters including execution time in month, a second MSHflexgrid will have 7x No of month cells to record monthly prograss. From the 2nd one , data is fed to chart.
The problem was, in earlier windows versions, when you create a new project, nothing is assigned to those cells and attemting to read them gave zero and did not cause problem, but in XP the project goes in an infinate loop, when I try to stop it, the visual basic crashes and I get the "Error sending report" Window. When I skipped that part in code for a "New Project" and do it only for "Existing Project", every thing worked fine.... ;)
Yet I do not understand why in single step mode, it opens the first grid but crashes with displaying MSchart while in "Run" mode F5, it just craches... :surprised
The code for displaying is simple .visible=True and .visible=False in the toolbar's select case code, so error in calculation is supposed to be done in the form load code(as I had it before correction)
Best regards, Thanks again

Maged,

Happy to hear that you found the problem and that you're on your way again.

Have fun

Yomet

Hi All
Happy new year all
I found the problem of dir is locked and could not be removed, it is the DIR command
if dir "D:\TMP" <> "" then
This command will lock D:\tmp untli you execute another DIR with different path, so
I used
Dir "c:\"
then d:\tmp can be deleted...
I hope it is useful to someone....Best regards and thanks for help

commented: Well Done +2

Maged,

Thanks for the insight, I would not have thought of this but will, try to, keep it in mind next time I have this kind of problem.

Happy new year to you too.

Yomet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.