Страница: 1 |
Вопрос: Доступ к методам | Добавлено: 14.10.03 09:08 |
Автор вопроса: ![]() |
Добрый день Как получить доступ к методам класса File (и к любым другим то же) Строка Imports System_IO результат не дала Help please Заранее спасибо. |
Ответы | Всего ответов: 2 |
Номер ответа: 1 Автор ответа: ![]() ![]() Вопросов: 5 Ответов: 100 |
Профиль | Цитата | #1 | Добавлено: 14.10.03 09:19 |
А почему System_IO? Если написать System.IO (через точку), то список методов раскрывается. Или не импортировать пространство имен, а прямо так и написать - Dim f as System.IO.File |
Номер ответа: 2 Автор ответа: ![]() ![]() ![]() ![]() ![]() ![]() ![]() Администратор ICQ: 326066673 Вопросов: 368 Ответов: 5968 |
Web-сайт: Профиль | Цитата | #2 | Добавлено: 14.10.03 10:00 |
Не очень ясен вопрос... Вот пример из MSDN про работу с классом File: Imports System Imports System.IO Imports System.Text Public Class Test Public Shared Sub Main() Dim path As String = "c:\temp\MyTest.txt" Dim fs As FileStream ' Delete the file if it exists. If File.Exists(path) = False Then ' Create the file. fs = File.Create(path) Dim info As Byte() = New UTF8Encoding(True).GetBytes("This is some text in the file.") ' Add some information to the file. fs.Write(info, 0, info.Length) fs.Close() End If ' Open the stream and read it back. fs = File.Open(path, FileMode.Open, FileAccess.Read) Dim b(1024) As Byte Dim temp As UTF8Encoding = New UTF8Encoding(True) Do While fs.Read(b, 0, b.Length) > 0 Console.WriteLine(temp.GetString(b)) Loop Try ' Try to get another handle to the same file. Dim fs2 As FileStream = File.Open(path, FileMode.Open) ' Do some task here. fs2.Close() Catch e As Exception Console.Write("Opening the file twice is disallowed.") Console.WriteLine(", as expected: {0}", e.ToString()) End Try fs.Close() End Sub End Class |
Страница: 1 |
|