Главная страница
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.051 c
1-1100076951
LEXX_55
2004-11-10 11:55
2004.11.21
Нужна помощь! Файл сохраняется не там где надо!


14-1097151015
Красная Майка
2004-10-07 16:10
2004.11.21
MMP - Липки 2004


14-1099252499
Поручик
2004-10-31 22:54
2004.11.21
Кто пользуется Оперой


4-1097234701
Falcon
2004-10-08 15:25
2004.11.21
Передача клавиатурногог фокуса стороннему приложению.


1-1099568342
InfMag
2004-11-04 14:39
2004.11.21
Получение списка файлов и папок или что-то поотдельности