Главная страница
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.017 c
6-30962
Фредди
2002-03-28 22:20
2002.06.10
Кто нибудь писал веб-сервер на Дельфи?


3-30685
Andrey__
2002-05-16 19:12
2002.06.10
Проблема с IBEvents в Delphi 6


3-30703
KOA
2002-05-18 12:33
2002.06.10
Убрать удаление записей в базе


14-30972
Timon
2002-05-06 10:57
2002.06.10
Bug или моя лажа?


1-30747
SuperVK
2002-05-30 10:32
2002.06.10
TRichEdit - перенос страницы