Hello to all, I'm trying to use the function below to print strings to a file. When I use Console.Write() or Console.WriteLine() the output file grows up 3MB or 4MB per seconds, but when I try to use StreamWriter or File.AppendAllText the output in the way shown below, the file grows up only in 20KB or 30KB per second. Why the print speed decreases too much when I use StreamWriter instead of Console.WriteLine()? What method should I use to write to a file maintaining the same speed of Console.WriteLine()? public static void PrintFunction() { //using (StreamWriter writer = File.AppendText(@"C:\OuputFile.txt")) using …

Member Avatar
Member Avatar
+0 forum 5

Hello, I have been using StreamWriters for a long and time and it has always worked but now I seem to be getting an Access Denied error while trying to save to the current users Desktop... Dim savePath As String = "C:\Users\Josh\Desktop\EpiPhone\029.csv" Using sw As New StreamWriter(savePath) '...Rest of code... End Using What are the most common problems with Access Denied while writing to the Desktop?

Member Avatar
Member Avatar
+0 forum 4

I am trying to write the information below (name, employee no., etc.) to a file using StreamWriter. I'm able to enter the data, click the save button, enter/change the save location and file name and save the document. When I open the saved document, its blank and none of the data is written. Any advice? Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim Save As New SaveFileDialog() Dim EmployeeDataFile As StreamWriter 'Configure Save Record Save.Filter = "Text files (*.txt)|*.txt|All Files (*.*)|*.*" Save.InitialDirectory = "C:\" Save.ShowDialog() 'Save employee data Try EmployeeDataFile = System.IO.File.AppendText(Save.FileName) EmployeeDataFile.WriteLine(txtFirstName.Text) EmployeeDataFile.WriteLine(txtMiddleName.Text) EmployeeDataFile.WriteLine(txtLastName.Text) …

Member Avatar
Member Avatar
+0 forum 1

Hi, The code shown below sucessfully saves text onto a line in a txt document, but using the array, I want to be able to save each piece of text on a separate line. How would I do this? Thanks in advance :) Dim filePath As String Dim objectWriter As StreamWriter Dim text(3) As String Dim int As Integer Sub Main() filePath = "C:\College.txt" objectWriter = New StreamWriter(filePath) For int = 0 To 3 Console.Write("Enter something here: ") text(int) = Console.ReadLine objectWriter.Write(text(int)) Next objectWriter.Close() Console.WriteLine("Text has been saved.") Console.ReadLine() End Sub

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm having a problem with using the streamWriter to write to a unicode file. Code as follows: [CODE] for(int i = 1; i < 1018; ++i) { std::wostringstream integer; integer << L"IDS_STRING" << i << L"\t"; wstring thisString = integer.str(); thisString = thisString + L"\"Spare String\""; wchar_t* SpareString = const_cast<wchar_t*>(thisString.c_str()); bool isPresent = std::find_if(load.begin(), load.end(), StartsWith1(thisString)) != load.end(); System::IO::StreamWriter^ WriteSpareStrings = gcnew System::IO::StreamWriter(L"Chinese.txt", true, System::Text::Encoding::Unicode); if(isPresent == false) { WriteSpareStrings->Write(SpareString); WriteSpareStrings->Write(L"\r\n"); } WriteSpareStrings->Flush(); WriteSpareStrings->Close(); } [/CODE] So, obviously I'm expecting the output to the file to be strings of "IDS_STRINGi "Spare String"", but instead all the strings are just …

Member Avatar
Member Avatar
+0 forum 1

I made a listview that display names using a streamreader. When I select a name and delete it the name that was below in the list will then take the information of the deleted name when it's displayed in the textboxes which shows name, address and email. How can I delete a name from the list so that it's gets completely deleted and dont leave behind any information? Im thinking it has something to to with the streamwriter and streamreader.

Member Avatar
Member Avatar
+0 forum 2

Basically I use text files to hold the program data, which is loaded in to variables when the program starts. I use StreamWriter to write to the text files when they update within the program. This is fine although the writer adds a extra line when I do not want this, which causes the program to error on the next use. This is what I mean: [CODE]For x = 1 to 4 FileWriter.WriteLine(user(x) & "," & pass(x)) Next[/CODE] Comes out as (the text doesn't matter here) 'line1 'line2 'line3 'line4 | <---- but the cursor goes here making the application …

Member Avatar
Member Avatar
+0 forum 3

I have been trying to write some strings to the notepad. I have successfullly written the first string , however when I try to add another string,It always over writes the first string I have written.Can you tell me a way where I can write strings to the next line all the time I want to write to the note pad thanks

Member Avatar
Member Avatar
+0 forum 10

So I have problem with a code I am writing, when I write a string to a text document, I get the following error; "Conversion from string "1, 1, 2, 3, 5, 8, 13, 21, 34, 55" to type 'Integer' is not valid." Please help; code below. Thanks in advance! [CODE]Imports System.IO Imports System.Numerics Public Class Form1 Dim path As String Dim clicked As Boolean Dim pastfib2 As BigInteger Dim pastfib As BigInteger Dim fib As BigInteger Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = "1, 1, " pastfib = 1 pastfib2 = 1 …

Member Avatar
Member Avatar
+0 forum 2

The End.