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

Вниз

Не могу открыть файл на чтение, из сетевой папки Read Only   Найти похожие ветки 

 
Andrews ©   (2002-03-27 15:40) [0]

Привет всем!

Не могу открыть файл на чтение, лежащий в сетевой папке с параметрами доступа "Только чтение", возникает ошибка "I/O error 65", если открыть "Полный доступ" все работает :o(

Файл открываю так:

AssignFile(f, FN);
Reset(F); //ошибка здесь

где FN := "\\server\data\ddmain.db";

где server имя компьютера в сети, а data пресловутая папка открытая для общего доступа

Заранее всем спасибо.


 
John Kayfolom   (2002-03-27 16:48) [1]

Reset открывает файл на чтение и запись. Нужно юзать OpenFile
Из хэлпа дельфей:
HFILE OpenFile(
LPCSTR lpFileName, // pointer to filename
LPOFSTRUCT lpReOpenBuff,// pointer to buffer for file information
UINT uStyle // action and attributes);
Где uStyle установить в OF_READ (Opens the file for reading only.)


 
John Kayfolom   (2002-03-27 16:53) [2]

В догонку - есть обертка апишной функции:
unit system
function FileOpen(const FileName: string; Mode: LongWord): Integer;
Вот кусок из хелпа:
var
iFileHandle: Integer;
iFileLength: Integer;
iBytesRead: Integer;
Buffer: PChar;
i: Integer
begin
if OpenDialog1.Execute then
begin
try
iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
Buffer := PChar(AllocMem(iFileLength + 1));
iBytesRead = FileRead(iFileHandle, Buffer, iFileLength);
FileClose(iFileHandle);
for i := 0 to iBytesRead-1 do
begin
StringGrid1.RowCount := StringGrid1.RowCount + 1;
StringGrid1.Cells[1,i+1] := Buffer[i];
StringGrid1.Cells[2,i+1] := IntToStr(Integer(Buffer[i]));
end;
finally
FreeMem(Buffer);
end;
end;
end;


 
Andrews ©   (2002-03-27 17:13) [3]

Что самое смешное, если файл лежит на флопе защищенным от записи все работает, никахих ошибок, а весь огород городится ради f

for I := 1 to 9 do
begin
FN := EDB_Path+S1+"."+MDiskExt[I];
if FileExists(FN) then
begin
AssignFile( f, FN);
Reset( F);
Size := Size + FileSize( F);
CloseFile( f);
end;
end;


 
ASV   (2002-03-29 11:18) [4]

Перед Reset добавь строку FileMode := 0



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

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

Наверх




Память: 0.47 MB
Время: 0.016 c
3-30719
jaric
2002-05-18 17:03
2002.06.10
Большая DBF таблица больше 1000000 записей комп умирает


6-30944
Kerrik
2002-03-21 20:29
2002.06.10
Траффик под Win98


1-30789
den12
2002-05-31 09:18
2002.06.10
Как получить свойства объекта


1-30867
MViper
2002-05-29 16:47
2002.06.10
Работа с dll


1-30909
FireWorks
2002-05-29 09:32
2002.06.10
Счестчик слов