Difference between using StreamWriter constructor and File.CreateText
What's the difference (CPU usage, MSIL, etc) between: StreamWriter sw = new StreamWriter("C:\test.txt"); and: StreamWriter sw = File.CreateText("C:\test.txt"); ? ...
What's the difference (CPU usage, MSIL, etc) between: StreamWriter sw = new StreamWriter("C:\test.txt"); and: StreamWriter sw = File.CreateText("C:\test.txt"); ? ...
Hey guys, Trying to push some coordinates, as well as some stuff specified in a form by the user, to an an array called "seatsArray". Here's my code: <div> <img onLoad="shiftzoom.add(this,{showcoords:true,relativecoords:true,zoom:100});" id="image" src="plan1.bmp" width="1024" height="768"> </div> <script type="text/javascript"> var s...
Hey guys, I've got a JS array which is writing to a text file on the server using StreamWriter. This is the line that does it: sw.WriteLine(Request.Form["seatsArray"]); At the moment one line is being written out with the entire contents of the array on it. I want a new line to be written after every 5 commas. Example array: BN,ST,A...
I want to append two text files together. I have one file with a carriage return line feed at the end. Observe file A which is 28 bytes. this is a line in the file\n then I have another file which is the same thing without the new line. Observe file B which is 26 bytes. this is a line in the file I want to append the sam...
I am new to visual basic and I am just playing around with it. I have a book that tells me how to read from a file but not how to write to the file with a button click. All I have is a button and a textbox named fullNameBox. When I click the button it gives me an unhandled exception error. Here is my code: Public Class Form1 Sub out...
What is the best way to build a program that is thread safe in terms that it needs to write double values to a file. If the function that saves the values via streamwriter is being called by multiple threads? Whats the best way of doing it? Code from comment: static void Main() { List<double> Values = new List<double...
Group, I'm looking for new and fun ways to write an array of strings to a .txt file. -This file will be rewritten every time its called and saved. -The file name will be dynamic enough that the .exe will know what string goes where. For example: ~/someFile.exe "fileName" "string|string|string|" -In this example someFile.exe is ca...
I need to update the students score with a new score but I cant get it to write to the line that the students current score it at. It just deletes the whole text. Alex,letmein,0 David,qwerty1,0 John,password,0 Paul,lion,0 Luke,bennett,0 Ronald,Mcdonald,0 Erin,german,0 Laura,Scotland,0 Ross,extra,0 Alan,beverage,0 Try fileName = "C:\Do...
So here's the code in C# .Net. string linie = txtFirstName.Text + "," + txtLastName.Text + "," + txtBirthday.Text + "," + txtEmail.Text + ","; StreamWriter write = new StreamWriter(@"D:/Hosting/2691577/html/gshccadmin/site1/excel_formdata/birthday_club.csv", true); write.WriteLine(linie); write.Flush(); ...
I have a file containing data that I'd like to monitor changes to, as well as add changes of my own. Think like "Tail -f foo.txt". Based on this thread, it looks like I should just create a filestream, and pass it both to a writer and reader. However, when the reader reaches the end of the original file, it fails to see updates I wr...
I have a class library which is deployed on an ISP server to be consumed by an ASP.NET web service. I'd like to keep track of any errors and in this case the windows event log is inaccessible to me. So I thought I'd write to a txt file using the StreamWriter class. Problem is if I don't give an absolute path and just a file name it tries...
I am reading data from a TXT file that requires me to replace some of the existing data, and then write it back to the file. The issue is, there are special characters in the file that get corrupted when I write the text back to the file. For example, I have a string in a file "foo.txt" that has the following "€rdrf +À [HIGH]". My ap...
Hey guys, having a bit of trouble here. So I have a load button that loads the file, and a save button the saves the file. I also have a exit button that closes the program. What I need help with is when I close the program, I wont to check whether there are any StreamReader or StreamWriter things that have not been closed. Heres what ...
I was trying to make the program write to a file that was named with a time stamp. Basically, saving a timestamp to a string value, I wanted it to create the file based on that time stamp. For example "Flight Manifest 10/14/2010 1:38:29 AM.txt" Whats the right way to do this? I tried something like this: string timeStamp = DateTime.No...
Hi, I'd like to open a text file and not allow any other processes to write to it. I understand I can do this with the following FileStream: Dim fs As New FileStream(_FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read) Once I have access like this I need to read all of the lines (I will use a StreamReader(fs)) and then I w...