About 1,430,000 results
Open links in new tab
  1. Create a new txt file using VB.NET - Stack Overflow

    Nov 12, 2010 · Here is a single line that will create (or overwrite) the file: File.Create("C:\my files\2010\SomeFileName.txt").Dispose() Note: calling Dispose() ensures that the reference to the file is closed.

  2. Creating and appending text to txt file in VB.NET

    May 13, 2016 · Using VB.NET, I am trying to create a text file if it doesn't exist or append text to it if exists. For some reason, though it is creating the text file I am getting an error saying process cannot access file. And when I run the program it is writing text, but how can I …

  3. How to: Create a File - Visual Basic | Microsoft Learn

    Dim path As String = "c:\temp\MyTest.txt" ' Create or overwrite the file. Dim fs As FileStream = File.Create(path) ' Add text to the file. Dim info As Byte() = New UTF8Encoding(True).GetBytes("This is some text in the file.") fs.Write(info, 0, info.Length) fs.Close() End Sub End Module. Use the file variable to write to the file.

  4. text files - Creating/editing textfile through VB.NET - Stack Overflow

    How do I code the algorithm below in VB.NET? Procedure logfile() { if "C:\textfile.txt"=exist then open the textfile; else create the textfile; end if go to the end of the textfile; write new line in the textfile; save; close; }

  5. How to: Write Text to Files - Visual Basic | Microsoft Learn

    Sep 15, 2021 · Use the WriteAllText method to write text to a file, specifying the target file and string to be added and setting append to True. This example writes the names of the files in the Documents and Settings directory to FileList.txt , inserting a carriage return between each for better readability.

  6. How to: Write Text to Files with a StreamWriter - Visual Basic

    Sep 15, 2021 · This example opens a StreamWriter object with the My.Computer.FileSystem.OpenTextFileWriter method and uses it to write a string to a text file with the WriteLine method of the StreamWriter class. Example

  7. How to Write to a Text File in VB .NET - Home and Learn

    The StreamWriter is used to write a stream of text to a file. Add another Button to the form you've been working on. Set the Text property of the button to " Write to File ".

  8. Creating files in isual Basic - Visual Basic Tutorial

    Feb 14, 2025 · To create a file , we use the following command. Each file created must have a file name and a file number for identification. As for the file name, you must also specify the path where the file will reside. For example: will create a text file by the name of sample.txt in My Document folder in C drive. The accompanied file number is 1.

  9. VB.NET - StreamWriter Example - Dot Net Perls

    Nov 10, 2023 · Here we use StreamWriter to create a new file, and then write 2 lines of text to it along with 2 newlines. Note how the System.IO namespace is imported at the top.

  10. Create a File Using VB.NET

    Jan 23, 2020 · Open this text file: FileInfo.CreateText Method. The FileInfo.CreateText method creates and opens a file for writing UTF-8 encoded text. If file already exists, this method opens the file. The following code snippet creates a file using the CreateText method that returns a StreamWriter object.

Refresh