Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.11.21;
Скачать: CL | DM;

Вниз

sharing violation   Найти похожие ветки 

 
TUser ©   (2004-11-04 14:34) [0]

Почему, если файл открыт, как rewrite(filevar) и программа туда чего-то пишет, то его можно при этом открыть в другой программе для чтения. А если пишем через TFileStream - то при попытке открыть его (в FAR"е, например) - получаем ошибку? Типа - файл занят.


 
panov ©   (2004-11-04 14:40) [1]

TUser ©   (04.11.04 14:34)

Смотря в каком режиме открываешь файл. см. глоб. переменную FileMode


 
TUser ©   (2004-11-04 15:02) [2]

FileMode (судя по справке) влияеть не Reset. Я открывал Rewrite"ом.
Когда через стрим - то стоит fmOpenWrite, никакого fmShareDeny... нет, т.е. вроде бы файл д.б. доступен в других программах (по крайней мере для чтения) - ан нет.


 
Rem ©   (2004-11-04 15:08) [3]

File open mode constants

File open mode constants are used to control the access mode to a file or stream.

Unit
SysUtils

Category
file management routines

const

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

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


Description

The file open mode constants are used when a file or stream is opened to control how it can be shared.

The TFileStream constructor has a Mode parameter that you can set to one of these constants:

Constant        Definition

fmCreate         If the file exists, open for write access,
                otherwise, create a new file.
                Unlike the other constants, which are declared
                in the SysUtils unit, this constant is
                declared in classes.pas.
fmOpenRead       Open for read access only.
fmOpenWrite      Open for write access only.
fmOpenReadWrite  Open for read and write access.
fmShareCompat    Compatible with the way FCBs are opened.
fmShareExclusive Read and write access is denied.
fmShareDenyWrite Write access is denied.
fmShareDenyRead  Read access is denied.
fmShareDenyNone  Allows full access for others.


 
VMcL ©   (2004-11-04 15:24) [4]

>>TUser ©  (04.11.04 14:34)

TFileStream.Create(..., fmCreate) открывает  в монопольном режиме. См. исходники VCL.


 
VMcL ©   (2004-11-04 15:29) [5]

>>TUser ©  (04.11.04 15:02) [2]

>Когда через стрим - то стоит fmOpenWrite, никакого fmShareDeny... нет, т.е. вроде бы файл д.б. доступен в других программах (по крайней мере для чтения) - ан нет.

Никому он ничего не должен :-)
Тогда срабатывает fmShareCompat = $0000. Ставь явно fmShareDenyNone или fmShareDenyWrite (см. [3]).



Страницы: 1 вся ветка

Текущий архив: 2004.11.21;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.024 c
14-1099458845
080D:07BBh
2004-11-03 08:14
2004.11.21
Генератор XML


14-1099610766
default
2004-11-05 02:26
2004.11.21
Забавная задачка


4-1097347227
XProger
2004-10-09 22:40
2004.11.21
Добвить строку в RichEdit


1-1099499465
lexa
2004-11-03 19:31
2004.11.21
Лингвистический анализ текста.


3-1098786783
Артем К.
2004-10-26 14:33
2004.11.21
Какие компоненты использовать для работы с MySQL Server?