HI,

I'm having a problem with saving some text in a while using the FileOpen Method, as shown below.

  Dim Filename As String
  Dim text As String = "Testing Testing"
        Console.Write("Enter new file name: ")
        Filename = Console.ReadLine
        Console.WriteLine()
        FileOpen(1, Filename , OpenMode.Binary, OpenAccess.Write)
        FilePut(1, text)
        FileClose(1)

I'd appreciate it if somebody could show me how to use this method correclty? (i.e. where would i insert the filepath?)

Thanks in advance :)

Collin

You can do this in one step as

Sub Main()

    Dim text As String = "line 1" & vbCrLf & "line 2" & vbCrLf & "line 3" & vbCrLf

    Dim path As String = My.Computer.FileSystem.CurrentDirectory
    Dim file As String = System.IO.Path.Combine(path, "myfile.txt")
    System.IO.File.WriteAllText(file, text)

End Sub

Modify the value of "path" as appropriate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.