XP v Win 7

I might have the wrong newsgroup .... aplogies if so.

The following code (originated from Turbopower, iPro) works in XP but fails
on the TFileStream.Create  in Windows 7 ("... cannot create file, access is
denied ..."). I have full access to the directory and fails even if running
as Administrator.

If you comment out the DeleteFile it works in both XP and Win7 - the
DeleteFile returns True.

If you step through the code (say a few seconds on each line, especially the
DeletFile line) then it all works ok, it's like Win7 has not deleted but
temporarily locked the file.

Any ideas ?

if not FileExists(FLocalFile) then begin
    FH := FileCreate(FLocalFile);
    FileClose(FH);
end;

if (RetrieveMode = rmReplace) then begin
      DeleteFile(FLocalFile);
{!!.11}
      LocalStream := TFileStream.Create(FLocalFile, fmCreate);
{!!.11}
      LocalStream.Position := 0;
0
Edwin
2/15/2010 3:42:26 AM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

3 Replies
854 Views

Similar Articles

[PageSpeed] 27

On Sun, 14 Feb 2010 19:42:26 -0800, Edwin Grimshaw
<EdwinGrimshaw@bigpond.com> wrote:

>I might have the wrong newsgroup .... aplogies if so.
>
>The following code (originated from Turbopower, iPro) works in XP but fails
>on the TFileStream.Create  in Windows 7 ("... cannot create file, access is
>denied ..."). I have full access to the directory and fails even if running
>as Administrator.
>
>If you comment out the DeleteFile it works in both XP and Win7 - the
>DeleteFile returns True.
>
>If you step through the code (say a few seconds on each line, especially the
>DeletFile line) then it all works ok, it's like Win7 has not deleted but
>temporarily locked the file.
>
>Any ideas ?
>
>if not FileExists(FLocalFile) then begin
>    FH := FileCreate(FLocalFile);
>    FileClose(FH);
>end;
>
>if (RetrieveMode = rmReplace) then begin
>      DeleteFile(FLocalFile);
>{!!.11}
>      LocalStream := TFileStream.Create(FLocalFile, fmCreate);
>{!!.11}
>      LocalStream.Position := 0;

Sure it's Win7 at fault?  I've caught my AV (Kaspersky) doing this
sort of thing although I can't figure out why.
0
Loren
2/15/2010 5:29:36 AM
"Edwin Grimshaw" <EdwinGrimshaw@bigpond.com> wrote in message 
news:214335@forums.codegear.com...
>
> if not FileExists(FLocalFile) then begin
>    FH := FileCreate(FLocalFile);
>    FileClose(FH);
> end;
>
> if (RetrieveMode = rmReplace) then begin
>      DeleteFile(FLocalFile);
> {!!.11}
>      LocalStream := TFileStream.Create(FLocalFile, fmCreate);
> {!!.11}
>      LocalStream.Position := 0;


Why are you creating the file if you are going to turn right around and 
delete it, just to create it yet again? Get rid of the first if not 
FileExists block.

-- 
Wayne Niddery (TeamB)
0
Wayne
2/15/2010 5:00:23 PM
On Mon, 15 Feb 2010 09:00:23 -0800, Wayne Niddery
<wniddery@chaffrogers.com> wrote:

>"Edwin Grimshaw" <EdwinGrimshaw@bigpond.com> wrote in message 
>news:214335@forums.codegear.com...
>>
>> if not FileExists(FLocalFile) then begin
>>    FH := FileCreate(FLocalFile);
>>    FileClose(FH);
>> end;
>>
>> if (RetrieveMode = rmReplace) then begin
>>      DeleteFile(FLocalFile);
>> {!!.11}
>>      LocalStream := TFileStream.Create(FLocalFile, fmCreate);
>> {!!.11}
>>      LocalStream.Position := 0;
>
>
>Why are you creating the file if you are going to turn right around and 
>delete it, just to create it yet again? Get rid of the first if not 
>FileExists block.

That's not his code.  Ask the Turbopower guys why they did it this
way.
0
Loren
2/15/2010 9:33:31 PM
Reply:

Similar Artilces:

Migrating Eudora 7 from Win XP to Win 7 64
I run Eudora 7 on my current Win XP machine. I'm getting a new Win Pro 64bit computer and want to install Eudora 7 on my new computer and move all of the old Eudora data from the Win XP to the Win 7 computer. I've searched and read, but I haven't found anything that lays out a step-by-step procedure for doing this. I've read that Win 7 won't let you store programs and writable data in the Program Files folder and found several (none of them crystal clear to me) workarounds. I read one fix that said if Eudora is installed in another file - for example C:\My Ut...

Tmaskedit acts differently on win xp and win 7
Using tmaskedit for socsec input. On win xp clicking in component highlights entire 9 char, in win7 enviornment only 1st 3 light up. Usiing delphi 2010 with advantage 11.1 db. ...

General Netwrok Setup Questions (Win XP and Win 98)
Allow me to apologize in advance if this is the wrong venue to post such a question, but this seemed to be the most general of them all. I would appreciate it if someone could help me out to make sure my network is secure. I checked with shields up and it didn't flag anything. I have computers running XP home and 98SE on my home network and connected to a D-Link router. I am networkingly challenged and have used Microsoft to set up my network 1. I use zonealarm on all computers and had to add the IP range from my router to my "trusted" list in order to be ab...

Can't Register Delphi 7 from Win 7
I recently bought Delphi 2010 Prof. edition and took advantage of getting a free copy of Delphi 7 Prof., which I would now like to use on my Win 7 machine. However I can't get past the Registration Dialog! When I start it up (in win xp compat. mode), I'm prompted to perform the registration, which I do and am told it was successful, but when the Wizard closes, I'm put back to the Registration dialog again! Any ideas on how to work around this??? James OK, so I installed it now on virtual machine (Win XP) within Win 7 and that went fine! The difference is that in the the XP...

Delphi 7 on XP connect to SQL 08 on Windows 7
Okay, this has me stumped. I'm still using my XP box to do development work in an old Delphi 7 project. The client has updated to SQL 2008 on Windows 7 and things run just fine. On my XP box I'm able to create an ODBC connection in Windows that connects to the SQL 08 instance on the Windows 7 box. But I cannot get my Delphi 7 project to connect for some reason. I did create a Windows 7 firewall inbound connection rule which is why the ODBC connection works. But again, when I run the Delphi 7 project it ju st won't. I've stepped through the code and all the connection string se...

Tabs on top saves screen space on Win 7 but not Win XP
I upgraded to FireFox 4 on both my home laptop (Windows 7 64-bit Home "premium") and my work computer (Windows XP 32-bit "professional"). The new feature "tabs on top" allows the tabs to use the same vertical space as the new Firefox menu button on the Win7 machine, but on WinXP, the tabs go below that button so I don't recover any vertical space. Is this an OS limitation of XP? Or can I somehow get the space back. By the way I really like the new look which seems to do a good job of getting more screen space for browsing. The new widescreen m...

Delphi 7 IDE Win 7 Mouse Wheel Scroll Issue
I've just upgrade from XP Pro to Win 7 64. After installing Delphi 7 I've run into a problem with the mouse wheel when I'm working in a unit. When I attempt to scroll the IDE moves to the first line of the unit and at that point the mouse wheel seems frozen, i.e. nothing happens if I attempt to move it forward or backwards - suspect it just keeps moving to the first line. I've tried a Logitech mouse and a Microsoft Mouse with both exhibiting the same behavior. Scroll wheel for both mice scrolled correctly in other Win 7 programs such as notepad and windows explorer. Mouse...

Win 7 and XP
I did a clean install of Win7 64 on a seerate partition and it activated fine. When I start up machine it only boots into XP, it gives no other otptions. Using a recovery boot disk for xp shows the other os and lets me boot into it. Both bootini files only show its own OS. Can someone recomend a boot manager that will show both OS's at startup. Do you think MS did not put a boot loader option on the WIN7 as it was supposed to be an upgrade, as it did with the RC and Beta versions. I cant see my earlier post? "Steve" <Me@excite.com> wrote in message news:Xns9C...

XP or Win 7?
How many of you have upgraded to Win 7 from XP? I decided it was time and bought me a 3 user home upgrade of Win7 since I was reloading by good ole trusty Dell desktop, my notebook came with Vista but downgraded to XP so I might put it on there. Is it me but for work related stuff for those who HAVE to stay with a MS Win workstation solution, I'm not seeing the reason to upgrade at work other than the fact that MS is ending support for XP? Support for XP is not being discontinued. Only for SP2 not SP3. SP3 Support is continuing for a while yet. Win7 should be a l...

known performance differences between v. 7 & v. 9 on Win 98?
Hello, and thank you in advance, I'm trying to resolve a performance issue in a Powerbuilder application that seems to have cropped up after upgrading from ASA 6.03 to ASA 8.02. It is my understanding that the original query against this app took about 9 seconds to run, but after upgrading, the query now takes between 2 and 5 minutes. The query itself implements about 4 UNIONS (printed out, the query is about 9 pages long! I didn't do it!), and I'm wondering if ASA 8.02 has changed the way it treats UNION statements from previous versions or if possibly this is a drive...

Install win 7 over XP
I still have one computer running XP. I also have a copy of Win 7. Is it possibe to install 7 over XP? Not a regulay windos user, 99% Linux so not up on the details of Windows. TIA Bob Bloggs wrote: > I still have one computer running XP. I also have a copy of Win 7. Is > it possibe to install 7 over XP? Not a regulay windos user, 99% Linux > so not up on the details of Windows. TIA > No. you cannot 'upgrade to Win7 from WinXP. It demands a new install. So. split the partition and install Win7, and have best of both worlds until March 2014... -- LWB ...

Win 7 XP Mode
Has anyone out there gotten drive mappings to work in XP Mode on Windows 7? What I am currently running in to is that I have some video production equipment (camera) that the company has had for a while and the vendor only has XP drivers available, but the system's OS was Vista, which we have upgraded to 7 for this experiment. What we are trying to do is install the software and drivers within XP Mode and see if we can rip the videos taken from the camera to a digital format. The XP Mode does recognize the TS drive letters, but they are not accessible when trying to save dir...

I wrote an application and used cracked delphi 7, after i bought delphi 7
I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? "I embezzled some money from my employer, returned the funds, and then got it back as a bonus. Can I still be arrested?" Uhhh .... didn't you just confess to a crime? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an appli...

XP Manifest problem in Delphi 7
Hi. I upgrade my app to Borland Delphi 7 and I have visual problems due to XP Manifest. I detect visual problems in several components(TPanel, TLabel, TPageControl, ...): components are painted with the parent background, not the color specified. It's possible to solve TPanel reassigning ParentBackground property to FALSE. But this solution is not valid to PageControl, for example. There are any solution/s about this problem with Delphi7 - XP manifest? Exists any way to display well this components? Thanks in advance. Regards Jose Jose Fco R. Palau wrote: > Hi. &...

Web resources about - XP v Win 7 - embarcadero.delphi.general

Ted Cruz Tempts Fate With New Focus on New Hampshire
Ted Cruz has a most unusual problem. He could plausibly win the first three states of the Republican nomination battle. But don’t pop the bubbly ...

'Making a Murderer': Filmmakers say media is 'demonizing' Steven Avery
People Magazine 'Making a Murderer': Filmmakers say media is 'demonizing' Steven Avery Daily Democrat The filmmakers behind "Making a Murderer," ...

'Spotlight' wins best picture at Critics' Choice Awards
USA TODAY 'Spotlight' wins best picture at Critics' Choice Awards USA TODAY LOS ANGELES — Spotlight edged forward in the Oscar race Sunday ...

Why the Carolina Panthers can beat the Arizona Cardinals in NFC title game
Three reasons why the Carolina Panthers can beat the Arizona Cardinals in next Sunday's NFC Championship Game.

Burkina Faso and Mali to coordinate forces after deadly attacks
By Matthew Mpoke Bigg and Nadoun Coulibaly OUAGADOUGOU (Reuters) - Burkina Faso and Mali have agreed to work together to counter the growing ...

US Embassy: Americans missing in Iraq
USA TODAY US Embassy: Americans missing in Iraq USA TODAY BAGHDAD (AP) — The U.S. Embassy confirmed Sunday that "several" Americans have gone ...

Jeremy Corbyn says we need back channels to ISIS to end to the Syrian war
The Labour leader stopped short of calling for dialogue with ISIS but compared the situation to when the British government had lines of communication ...

Crews Resume Search for Missing California Ski Instructor
Crews have resumed their search for a ski instructor who went missing at a Northern California ski resort

Microsoft’s Word Flow keyboard on Windows Phone is coming to iOS
Having ported its Cortana intelligent personal assistant from Windows Phone to iOS, Microsoft is apparently set to bring another key functionality ...

Marco Rubio is so worried about ISIS he bought a gun to fight them off
On Sunday, U.S. Senator Marco Rubio (R-FL) managed to insert himself into the sweet spot between two of the hottest topics in the presidential ...

Resources last updated: 1/18/2016 8:19:08 AM