Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Filemodes with Assignfile and Reset

Posted on 2001-07-16
9
Medium Priority
?
1,265 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
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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

972 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