Solved

Filemodes with Assignfile and Reset

Posted on 2001-07-16
9
1,252 Views
Last Modified: 2012-05-04
Hi, Im using AssignFile and Reset in my application, and this seems to cause a problem. I need to be able to copy the opened files (for backup) when the application is running, and I cant do that! They are locked. I've looked at the global variable FileMode, but the default is already the least restricted, namely Read/Write. I could of course use a stream, and change all my calls, but it's a lot of calls... So, is it possible to open with other filemodes, when using Reset?

Pede
0
Comment
Question by:pede
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6285386
maybe it helps

if you open the file in readonly-mode
0
 
LVL 1

Author Comment

by:pede
ID: 6285410
I need to be able to write to the files, so that's not an option :0( I know this could cause problems if Im writing to the file while backing up, but it's not a huge problem in my application.


0
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 6285453
Hi,
I don't understand why you can't copy these files. Reset opens files for read/write but they are still readable by other apps (including copying).

Regards, Geo
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:bugroger
ID: 6285476
HI,

I think the best will be to use

 CreateFile, Read/WriteFile, CloseHandle

and change all your calls !

GL
 BUG
0
 
LVL 1

Author Comment

by:pede
ID: 6285602
I cant copy the files using the program PcAnyWhere, thats why I thought they where opened in the wrong way. It seems that PcAnyWhere can't copy any files at all, if another progam are using them. I tried to make a new Word document, opened it with Word and made a copy of the file. No problems. Then I tried to copy it with PcAnyWhere, and it failed.

Points goes to Geobul, since his comment made me try this.

Pede
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6286367
Yeah I have been wondering about this myself. I am using Win 2000 and when I was using Win 98 I could use xcopy directly to backup the registry but in Win 2000 it doesn't work because the registry files are locked down. I have yet to find away to do it programmically but I know it is possible because the Win 2000 backup utility does it. So if anybody has a solution to this I will award 100 points to them myself. :>)


The Crazy One
0
 

Expert Comment

by:ms99
ID: 6287686
Hi Pede,

These constants control the way you open a file:

const fmOpenRead       = $0000;
const fmOpenWrite      = $0001;
const fmOpenReadWrite  = $0002;

const fmShareCompat    = $0000;
const fmShareExclusive = $0010;
const fmShareDenyWrite = $0020;
const fmShareDenyRead  = $0030;
const fmShareDenyNone  = $0040;

Besides opening for read/write you must also set Filemode to fmShareDenyNone or fmShareDenyWrite to let other applications read your files:

assignFile(f,'file.dat');
filemode := fmOpenReadWrite or fmShareDenyNone;
reset(f);


0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6288137
I didn't try it, but was just wondering... perhaps a MemoryStream can do it?
0
 
LVL 1

Author Comment

by:pede
ID: 6289028
Im sorry I forgot to assign the points, but the question is closed already. But some nice info there, ms99. The Delphi help didn't include all those constants.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month3 days, 15 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question