Questions tagged [streamwriter.write]

30 questions
26
votes
8 answers

StreamWriter.Write doesn't write to file; no exception thrown

My code in C# (asp.net MVC) StreamWriter tw = new StreamWriter("C:\\mycode\\myapp\\logs\\log.txt"); // write a line of text to the file tw.Write("test"); The file is created but is empty. No exception is thrown. I have never seen this before and I…
sarsnake
  • 26,667
  • 58
  • 180
  • 286
6
votes
2 answers

How write special character (é, è) with StreamWriter?

My problem : I want to write datas with a StreamWriter (my String contains letters é and è) but it doesn't work. Without this letters, it works. The error : Cannot close the stream My code : string postString = "id=" + sIdTransaction + "&nom=" +…
user2471450
  • 107
  • 1
  • 2
  • 7
6
votes
4 answers

C# Write to multiple files without constantly closing/reopening streams. SteamWriter?

I am trying to read in a table from an Access database, and then sort the data in that table out to a number of text files. The clincher is that the filename to write to is dependant upon values in each record. This is officially my first C#…
Daniel Ward
  • 103
  • 1
  • 1
  • 5
2
votes
1 answer

C# irc client streamwriter just send one word

i have source irc client from some site. this is the some code : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; …
kresek
  • 129
  • 2
  • 10
1
vote
1 answer

How to Ignore lines with StreamWriter WriteLine

trying to figure out how to ignore or stop specific lines from being written to file with StreamWriter. Here is the code I'm working with from How to pass arguments to program when using variable as path : $LogDir = "c:\users\user" # Log file…
user18982890
1
vote
0 answers

StreamWriter cannot be disposed

I just create a class named WriteLog,this class contains the following methods: //First Version: public void Add(string location, string words) { StreamWriter sw = new StreamWriter(location); …
Yyh
  • 103
  • 7
1
vote
2 answers

streamwriter doesn't save all the listview items to text file

so im using this code to save my listview items into a text file: SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = Application.ExecutablePath; sfd.Filter = "Text Files (*.txt)|*.txt"; sfd.Title = "Save Text…
Omarrrio
  • 1,075
  • 1
  • 16
  • 34
1
vote
3 answers

Get File timstamp and pipe with output of filelist in C#

My requirement is to read a file location retrieve the list of .jpg & .xml files along with their timestamp and write it to a file. I am new to C#, so far i have been able to get the file list and write the output to a file, but i am not sure how to…
user2385057
  • 537
  • 3
  • 6
  • 21
0
votes
1 answer

C# System.IO : The process cannot access the file path because it is being used by another process

I am trying to debug the code for uploading the .xlsx file through my application in my local system. At the time of appending log data to the log file this exception The process cannot access the…
0
votes
1 answer

streamWriter.Write hangs when writing large string, but API operation completes successfully

I have a xamarin forms app that makes API calls, and when the api calls involve very small json strings they work perfectly. An example payload that works…
0
votes
1 answer

Determining the line a specific piece of code is on in text file

I am currently writing a program in Visual Basic .Net. In one specific part of the program I am trying to read from a specific line in a text file, change one of the data values in that file (data values are held separate by ",") and overwrite the…
0
votes
2 answers

Can StreamWriter save an entire Class?

I have created a class that requests user input (7 textboxes of individual data) I need to save that data for later use in a flat file using the StreamWriter Class. Do I have to create individual instances for each field? private void…
Victor
  • 9
  • 8
0
votes
2 answers

How does C# understand an .txt file as output for the main?

The following code in the main is written: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace text_test { class Program { static void Main(string[]…
0
votes
0 answers

Have user select StreamWriter filepath and name

I have a GUI where the user is capable of logging data that comes in from the serial port. I have it set up where I can specify the filename and path that the streamwriter uses in the code, but I would like to have the user select their own path and…
0
votes
1 answer

write file name with parameter inside for loop

I want to create a list with all the numbers between 0000000 - 9999999 and to create a new file every 50000 rows. I tried this code: using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"E:\numbers" + fileparam + ".txt")) { for…
YossiH
  • 17
  • 5
1
2