Skip to main content

Questions tagged [streamwriter]

StreamWriter is designed for character output in a particular encoding, whereas classes derived from Stream are designed for byte input and output.

streamwriter
-1 votes
1 answer
57 views

OutOfMemory Excpetion when write a large txt file vb.net

In my program recovering data from the db (there are over 500k lines) I create a path with this data and write it in a file (in the db as a where clause I insert what the date range is, the lower it ...
DevMD's user avatar
  • 27
1 vote
1 answer
58 views

Delete a string value in a CSV File with C#

I deleted my previous post in hopes this one is better and clear to be able to get help. I appreciate it. So far, with my code I am uploading a CSV file to format it as: I have skip the headers and ...
Ivonne Aspilcueta's user avatar
0 votes
2 answers
42 views

need to close after FILE.READLINES

I need to read all content of a file but keep only some of the content and append new content. So I tried to use READLINES filter the lines I need to keep then rewrite the file with the kept lines and ...
Ernesto's user avatar
  • 35
0 votes
1 answer
177 views

ASP.NET - HttpResponse.WriteAsync() vs HttpResponse.Body.WriteAsync() vs HttpResponse.BodyWriter.WriteAsync()

In ASP.NET one has three options (that I know of) for writing directly to the response buffer. Given the following data: var str = "Hello World"; var bytes = Encoding.UTF8.GetBytes(str); We ...
user3163495's user avatar
  • 3,285
0 votes
0 answers
20 views

NamedPipeClientStream stalls after the first ReadLineAsync, and stalls on the first WriteLineAsync

I chose NamedPipes over TCP because I needed two applications on the same machine to talk to each other. I wanted exceedingly simple, quick, and easy, unfortunately it has proven to be the opposite. ...
Zoop's user avatar
  • 1,015
0 votes
1 answer
96 views

streamwriter and special characters & ’

To my understanding when I write a file using notepad++ I can write the symbols ’ and & without a problem in a text file. Both are valid ASCI symbols and they are not that exotic either. & = ...
Peter's user avatar
  • 2,214
0 votes
0 answers
37 views

How to Remedy Error System.UnauthorizedAccessException in My Console App?

I've programmed a console app using C#. When I run the console app I receive the error noted above. My programming logic is as follows: class Program { static void Main(string[] args) { ...
SidC's user avatar
  • 3,171
0 votes
2 answers
170 views

How do I download an xml file written with StreamWriter as an xml file

I have an XML file written in C# using StreamWriter with this code: String filename = Session.SessionID + ".xml"; String filepath = "h:\\root\\home\\mchinni-001\\www\\site1\\OUTFolder\\&...
Mike Chinni's user avatar
0 votes
1 answer
62 views

C# StreamWriter with using-block inside a while loop intermittently fails on slow network drive

I have a logging class in which I spawn a Task to append all messages from a BlockingCollection<string> to the log file, sleep two seconds, and repeat infinitely, until the fifo is completed. ...
amonroejj's user avatar
  • 633
0 votes
1 answer
92 views

C# Export Logs to 2 txt files

So I have a button made from my xaml file (view), called Export. When the user clicks on it, the logs created during the run of the app get exported to Logs.txt. If there are Warnings, Errors or ...
PinkGoat_'s user avatar
0 votes
0 answers
36 views

Does a MailMessage Attached to a Stream Generate a File?

In one method I have the below code: var newMessage = new MailMessage(); newMessage.Attachments.Add(new Attachment(ToStream("testAttachment"), MediaTypeNames.Text.Plain)); Then I have this ...
user98's user avatar
  • 17
1 vote
1 answer
50 views

How to ignore commas in cell value when using StreamWriter to write to csv output

I am processing a .txt file, which needs to be repeated every 10 lines. I then want to turn this into a .csv file. However, some of the .txt file contains commas which I want to keep in a single cell ...
Tommy K's user avatar
  • 1,799
0 votes
0 answers
71 views

Does WriteAllLines delete the existing file and recreate it, or overwrite the data inside it?

I use the File.WriteAllLines() method in my project. The txt file is to be synced to a remote server (via another application, Autodesk Docs in my case) upon Save action. I am not sure why, but using ...
IdoEng's user avatar
  • 11
3 votes
2 answers
253 views

C# StreamReader throws OutOfMemoryException on last line when splitting large delimited text file

I am writing a function in C# to split a large delimited file into smaller delimited files. I am writing this function because a 2.7 GB file was taking hours to ETL and was causing a bottleneck to ...
zBomb's user avatar
  • 361
1 vote
1 answer
103 views

C# Unable to overwrite file contents when file extension is .txt

I am attempting to write a string to a file that the user specifies using the SaveFileDialog component. The output file is created and populated successfully if it does not already exist. However, if ...
M Markov's user avatar
0 votes
1 answer
27 views

StreamWriter.Write that returned by a method not working

I have a program file in C# that in some point looks like this: var lowest3Students = studentAVGsOrdered.Take(3); using var writer4 = GetStreamWriter(folder, "file4.txt"); WriteStudents(...
mz1378's user avatar
  • 2,430
0 votes
1 answer
206 views

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 ...
Akbar Shaik's user avatar
0 votes
1 answer
58 views

process cannot access the file while trying to use StreamWriter [duplicate]

The process cannot access the file 'C:\csharp\notebook.txt' because it is being used by another process. How is it used by another process, if I haven't used StreamWriter yet? I want to add new text ...
Michał's user avatar
  • 23
-1 votes
2 answers
127 views

How do I open with read-only mode while saving csv file?

In C#, my program creates *.csv file. And append data to this file every 1ms. While append data, when I open *.csv file, this error occurs I JUST want to open "ONLY READ MODE" while append ...
BobKim's user avatar
  • 9
1 vote
1 answer
60 views

Text file is locked for openning when running the script but I can open it manually

I have the following PowerShell script: do{ $Error[0]= $null $StreamWrite = [System.IO.StreamWriter]::new($PathToTextFile,$true,[system.Text.Encoding]::Unicode) }while ($Error[0] -ne $...
POL's user avatar
  • 21
1 vote
2 answers
42 views

SerializeObject & StreamWriter created file not complete

here is my code : string json = JsonConvert.SerializeObject(stocksArticles,Formatting.Indented); StreamWriter sw = new StreamWriter("Export\\Stocks.json"); sw.Write(json); it's working fine ...
ced's user avatar
  • 23
0 votes
1 answer
92 views

using Steamwriter to write to a file gets stuck in foreach loop

I'm trying to create a small program that takes a html file as an input, and writes all links into a new output file. My problem is that the output file is empty. When debugging, it looks like I get ...
Schmuli's user avatar
  • 21
1 vote
1 answer
124 views

"WriteLine" stop writing a file. (Windows PowerShell)

I am trying to create a script for the university, that sorts the number of processes in the system by their handles number and saves them in a file. So far so good, sounds easy. But when I thought I ...
Altiubb's user avatar
  • 13
0 votes
1 answer
127 views

How to access a relative URI using StreamReader in C#

So I'm trying to read/write to a generic .dat file which contains plain text. I've been trying to do it with StreamReader/Writer as this seemed to be the neatest way of doing things. The data.dat file ...
AuthorBrotherGames's user avatar
-1 votes
1 answer
102 views

How to edit specific line in a textfile?

I know, that i can use ReadAllLines method and edit line using it's index. But this way not good for huge files. For example, i have file with 800,000 lines, and i need to find a line, which contains &...
Murrchalkina's user avatar
3 votes
2 answers
463 views

In C#, using "using" results in errors, is there a better practice than just not using "using"?

I have the following method: [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "If we dispose of the csvWriter, it won't be ...
Brian Kessler's user avatar
-1 votes
1 answer
152 views

StreamWriter fails to create a text file inside a folder with added DateTime.Now [duplicate]

I wanted to add a timestamp to the writing file and tried this: TextWriter iterationLogger = new StreamWriter($"{DateTime.Now} Iteration log.txt"); Then StremWritter throws exception The ...
Humble Newbie's user avatar
-3 votes
1 answer
1k views

C# "The process cannot access the file because it is being used by another process" error

I've been trying to figure out what's my error here for a few minutes now. can someone help? public void UpdateItemList(string word, string replacement) { StreamReader ...
tin's user avatar
  • 15
1 vote
1 answer
360 views

Do I need to dispose of StreamWriter when generating a stream from a string?

So I have the following code to convert a string to a MemoryStream https://stackoverflow.com/a/1879470/2987066 public static Stream GenerateStreamFromString(string s) { var stream = new ...
JKennedy's user avatar
  • 18.6k
0 votes
1 answer
118 views

Within a File StreamWriter scope how to get the Total lines counts in a file

How to do get the Total lines of the file when we are within in a StreamWriter scope. Based on the total number of lines count I am writing some more lines at the end of the file. I have tried the ...
Kumas's user avatar
  • 45

15 30 50 per page
1
2 3 4 5
51