Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.026 c
1-1098961158
pasha_golub
2004-10-28 14:59
2004.11.21
Мат, округлние


14-1099469043
Sergey_Masloff
2004-11-03 11:04
2004.11.21
Визуальное наследование, Суслики(с) и оффтопики в чужих ветках


14-1099360771
Sus
2004-11-02 04:59
2004.11.21
Кто?


14-1099551919
BiN
2004-11-04 10:05
2004.11.21
Транспортная революция. Будет ли она?


3-1098693352
Term
2004-10-25 12:35
2004.11.21
Проблема с запросом




   Наверх