Visual FoxPro Toolkit for .NET

FPuts() Method

Receives a FileStream and a string as parameters and adds the string to the FileStream and then appends a carriage return followed by a line feed

[VisualBasic]

Public Shared Function FPuts(ByRef oFileStream As FileStream, ByVal cString As String) As Integer
Public Shared Function FPuts(ByRef oFileStream As FileStream, ByVal cString As String, ByVal nCharactersWritten As Integer) As Integer

[C#]

public static int FPuts(ref FileStream oFileStream, string cString)
public static int FPuts(ref FileStream oFileStream, string cString, int nCharactersWritten)

Example

[VisualBasic]

Dim goErrFile As System.IO.FileStream

If File("errors.txt") Then ' Does file exist?

goErrFile = FOpen("errors.txt") ' If so, open read-write

Else

goErrFile = FCreate("errors.txt") ' If not, create it

End If

If goErrFile.Handle.ToInt32() < 0 Then 'Check for error opening file

'No errors. If so handle them here

Else

FPuts(goErrFile, "Kamal Patel")

End If

FClose(goErrFile) ' Close file

[C#]

System.IO.FileStream goErrFile ;

if(VFPToolkit.files.File("errors.txt"))

goErrFile = VFPToolkit.files.FOpen("errors.txt");

else

goErrFile = VFPToolkit.files.FCreate("errors.txt");

if(goErrFile.Handle.ToInt32() < 0)

//No errors. If so handle them here

else

VFPToolkit.files.FPuts(goErrFile, "Kamal Patel");

VFPToolkit.files.FClose(goErrFile) // Close file

Implementation

[VisualBasic]

Public Shared Function FPuts(ByRef oFileStream As FileStream, ByVal cString As String) As Integer
'Add a carriage return and line feed then write the string
'cString = cString + "\r\n"
Return FWrite(oFileStream, cString) + FWrite(oFileStream, "\r\n")
End Function
Public Shared Function FPuts(ByRef oFileStream As FileStream, ByVal cString As String, ByVal nCharactersWritten As Integer) As Integer
Return FWrite(oFileStream, cString, nCharactersWritten) + FWrite(oFileStream, "\r\n")
End Function

[C#]

public static int FPuts(ref FileStream oFileStream, string cString)
{
//Add a carriage return and line feed then write the string
//cString = cString + "\r\n";
return FWrite(ref oFileStream, cString) + FWrite(ref oFileStream, "\r\n");
}
public static int FPuts(ref FileStream oFileStream, string cString, int nCharactersWritten)
{
//Add a carriage return and line feed then write the string
return FWrite(ref oFileStream, cString, nCharactersWritten) + FWrite(ref oFileStream, "\r\n");
}

Requirements

Namespace:VFPToolkit

Class:VFPToolkit.files

Platforms:Windows98, WindowsNT4.0, WindowsMillenniumEdition, Windows2000, WindowsXPHomeEdition, WindowsXPProfessional, Windows.NETServerfamily

Assembly:VFPToolkit (in VFPToolkitNET.dll)

See Also

VFPToolkit.files Members | VFPToolkit Namespace