thefile = EnsureSlash(Dir1.Path) & myfile
'**********************************************************
' Чтение файла
'----------------------------------------------------------
Public Function FileRead(FileName As String) As String
Dim handle As Integer
handle = FreeFile()
Open FileName For Binary Access Read Shared As #handle
FileRead = Space(FileLen(FileName))
Get #handle, , FileRead
Close #handle
End Function
'**********************************************************
' Проверка блокировки файла
'----------------------------------------------------------
Public Function FileLocked(ByRef FileName As String) As Boolean
Dim h As Integer
On Error GoTo Error_Open
FileLocked = True
h = FreeFile()
Open FileName For Append Access Read Write Lock Read Write As #h
Close #h
FileLocked = False
Exit Function
Error_Open:
End Function
Private Sub Scan()
..... 'Некоторый код
'Начинаем сканирование
On Error Goto ErrSub
...
.... 'внутри цикла
Retry:
.... 'сканируем очередной файл
.... 'обрабатываем его
Ignore:
Next
Exit Sub
ErrSub:
Dim Answer As Integer
Answer = MsgBox("Невозможно получить доступ к " & vbCrLf & sFileName & vbCrLf, _
vbAbortRetryIgnore + vbExclamation, "Сканирование...")
Select Case Answer
Case vbAbort
Debug.Print "Отменяем..."
Exit Sub
Case vbRetry
Debug.Print "Повторная попытка..."
GoTo Retry
Case vbIgnore
Debug.Print "Игнорируем..."
GoTo Ignore
End Select
End Sub
cd.FileName = FileName
cd.ShowSave
FileName = cd.FileName
Open FileName For Binary As #123
nFileLength = LOF(123)
ReDim fil(nFileLength - 1)
Get #123, , fil
Close #123
Open FileName For Binary As #321
Put #321, , fil
Number used in the Open statement to open a file. Use file numbers in the range 1–255, inclusive, for files not accessible to other applications. Use file numbers in the range 256–511 for files accessible from other applications.
Open FileName For Binary As #444
nFileLength = LOF(444)
ReDim fil(nFileLength - 1)
Get #444, , fil
Close #444
Open FileName For Binary As #445
Put #445, , fil
Close #445
Сейчас этот форум просматривают: SemrushBot, Yandex-бот и гости: 95