FileSystem.Print(Int32, Object[]) Metoda
Definicja
Zapisuje dane w formacie wyświetlanym w postaci sekwencyjnego pliku.Writes display-formatted data to a sequential file.
public:
static void Print(int FileNumber, ... cli::array <System::Object ^> ^ Output);
public static void Print (int FileNumber, params object[] Output);
static member Print : int * obj[] -> unit
Public Sub Print (FileNumber As Integer, ParamArray Output As Object())
Parametry
- FileNumber
- Int32
Wymagany.Required. Dowolna prawidłowa liczba plików.Any valid file number.
- Output
- Object[]
Opcjonalny.Optional. Zero lub więcej wyrażeń rozdzielanych przecinkami do zapisu w pliku.Zero or more comma-delimited expressions to write to a file.
Ustawienia argumentu Output
są następujące:The Output
argument settings are:
T:System.IO.IOException
: tryb pliku jest nieprawidłowy.T:System.IO.IOException
: File mode is invalid.
T:System.IO.IOException
: FileNumber
nie istnieje.T:System.IO.IOException
: FileNumber
does not exist.
Przykłady
Ten przykład używa funkcji Print
i PrintLine
do zapisywania danych do pliku.This example uses the Print
and PrintLine
functions to write data to a file.
FileOpen(1, "c:\trash.txt", OpenMode.Output) ' Open file for output.
Print(1, "This is a test.") ' Print text to file.
PrintLine(1) ' Print blank line to file.
PrintLine(1, "Zone 1", TAB(), "Zone 2") ' Print in two print zones.
PrintLine(1, "Hello", "World") ' Separate strings with a tab.
PrintLine(1, SPC(5), "5 leading spaces ") ' Print five leading spaces.
PrintLine(1, TAB(10), "Hello") ' Print word at column 10.
' Assign Boolean, Date, and Error values.
Dim aBool As Boolean
Dim aDate As DateTime
aBool = False
aDate = DateTime.Parse("February 12, 1969")
' Dates and booleans are translated using locale settings of your system.
PrintLine(1, aBool, " is a Boolean value")
PrintLine(1, aDate, " is a date")
FileClose(1) ' Close file.
Uwagi
Funkcje Print
i PrintLine
zapewniają zgodność z poprzednimi wersjami i mogą mieć wpływ na wydajność.The Print
and PrintLine
functions are provided for backward compatibility and may affect performance. W przypadku aplikacji, które nie są starsze, obiekt My.Computer.FileSystem
zapewnia lepszą wydajność.For non-legacy applications, the My.Computer.FileSystem
object provides better performance. Aby uzyskać więcej informacji, zobacz dostęp do plików przy użyciu Visual Basic.For more information, see File Access with Visual Basic.
Print
nie zawiera wysuwu wiersza na końcu wiersza; jednak PrintLine
zawiera znak wysuwu wiersza.Print
does not include a line feed at the end of a line; however, PrintLine
does include a line feed.
Dane zapisywane przy użyciu Print
są zwykle odczytywane z pliku przy użyciu LineInput
lub Input
.Data written with Print
is usually read from a file by using LineInput
or Input
.
Jeśli pominięto Output
dla PrintLine
, do pliku zostanie wydrukowany pusty wiersz. w przypadku Print
nic nie jest wyjściowe.If you omit Output
for PrintLine
, a blank line is printed to the file; for Print
, nothing is output. Wiele wyrażeń oddzielonych przecinkami zostanie wyrównane na granicach tabulatora, ale mieszanie przecinków i TAB
może spowodować niespójne wyniki.Multiple expressions separated with a comma will be aligned on tab boundaries, but mixing commas and TAB
may cause inconsistent results.
W przypadku danych Boolean
jest drukowana True
lub False
.For Boolean
data, either True
or False
is printed. Słowa kluczowe True
i False
nie są tłumaczone, niezależnie od ustawień regionalnych.The True
and False
keywords are not translated, regardless of the locale.
Dane daty są zapisywane w pliku przy użyciu standardowego formatu daty krótkiej rozpoznawanego przez system.Date data is written to the file by using the standard short date format recognized by your system. Gdy składnik daty lub godziny jest nieobecny lub równy zero, tylko podana część jest zapisywana do pliku.When either the date or the time component is missing or zero, only the part provided is written to the file.
Nic nie jest zapisywana w pliku, jeśli Output
dane są puste.Nothing is written to the file if Output
data is empty. Jeśli jednak Output
danych listy DBNull
, Null
jest zapisywana w pliku.However, if Output
list data is DBNull
, Null
is written to the file.
W przypadku danych Error
dane wyjściowe są wyświetlane jako Error errorcode
.For Error
data, the output appears as Error errorcode
. Słowo kluczowe Error
nie jest tłumaczone niezależnie od ustawień regionalnych.The Error
keyword is not translated regardless of the locale.
Wszystkie dane zapisywana w pliku przy użyciu Print
są oparte na międzynarodowym. oznacza to, że dane są poprawnie sformatowane przy użyciu odpowiedniego separatora dziesiętnego.All data written to the file by using Print
is internationally aware; that is, the data is correctly formatted using the appropriate decimal separator. Jeśli użytkownik chce, aby dane wyjściowe były używane przez wiele ustawień regionalnych, należy używać Write
.If the user wishes to output data for use by multiple locales, Write
should be used.
Zapis w pliku przy użyciu funkcji Print
lub PrintLine
wymaga Write
dostępu z wyliczenia FileIOPermissionAccess
.Writing to a file by using the Print
or PrintLine
functions requires Write
access from the FileIOPermissionAccess
enumeration. Aby uzyskać więcej informacji, zobacz FileIOPermissionAccess.For more information, see FileIOPermissionAccess .
Dotyczy
Zobacz też
- PrintLine(Int32, Object[])
- FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)
- SPC(Int16)
- TAB
- Write(Int32, Object[])
- WriteLine(Int32, Object[])
- Dostęp do plików za pomocą Visual BasicFile Access with Visual Basic
- Porady: zapisywanie tekstu do plików w Visual BasicHow to: Write Text to Files in Visual Basic
- Instrukcje: wpisywanie tekstu do pliku za pomocą StreamWriter — (Visual Basic)How to: Write Text to a File with a Streamwriter (Visual Basic)