Skip to main content

All Questions

Tagged with
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
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
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
0 votes
0 answers
132 views

How to check stream writer flush called or not?

I have 2 places where I am calling writer.Flush() method like: StreamWriter writer; .... writer.Flush(); How to check was writer.Flush() called or not? there is my code: var writer = new ...
Dmytro Kryvoruchenko's user avatar
-1 votes
1 answer
1k views

How to ignore special characters in string while writing to CSV in c# [duplicate]

I am using StreamWriter to write records in csv Data = "abcd+ " , " + "Error + " , " + result.Message; using (StreamWriter streamWriter = new StreamWriter("c:/temp/...
Kavita Korgaonkar's user avatar
0 votes
2 answers
2k views

How do I overwrite a file if it already exists?

I'm making a text editor using fastColoredTextbox. I have a button that allows you to save your text onto your pc. The problem is that it throws an exception when the user tries to save the file as a ...
John's user avatar
  • 1
0 votes
1 answer
996 views

C # - .Net Core Write an ANSI encoded text file

I have to create an ANSI encoded txt file, because the system where I have to load it only reads ANSI and does not read UTF-8. I tried to follow various threads but nothing worked, now my code is this:...
Luca Vasapolli's user avatar
1 vote
2 answers
476 views

StreamWriter keeps writing to the same file after instantiating it again for another file

I'm trying to implement a simple file-logger object, with the possibility to truncate the file when its size reaches a threshold. I am using a StreamWriter, which gets written to at each call of the ...
Gabriel Macovei's user avatar
0 votes
1 answer
577 views

Can not read from the text file specified in c#.net [closed]

I'm trying to read a text file in my C# console application, however it doesn't read from the text file specified in c#.net, how can I fix it? My code: string docPath = Environment.GetFolderPath(...
Bizzie's user avatar
  • 47
-1 votes
2 answers
680 views

What delimiter can be used for .csv that has "," in it's column

I want to read .csv file and write to other .csv file. I use streamwriter and use string.split with delimiter (','). using (StreamWriter file = new StreamWriter(destFile, true)) { ...
irham dollah's user avatar
0 votes
1 answer
37 views

Why certain row shows different column's data in c#?

I want to write certain column from input file to the output file. My code looks like this: try { using (StreamWriter file = new StreamWriter(@"outputfile.csv", true)) ...
irham dollah's user avatar
0 votes
1 answer
285 views

CSV Helper, Write Row to file even in case user closes the app

I have to be able to write rows to CSV even when user closes the app in the middle of writing to file. I'm using CSVHelper and it creates my file, but nothing is written to it when I close it during ...
Dunnoman's user avatar
-1 votes
2 answers
100 views

Read delimited file and transform to a positional layout

I have a .txt file with this example, with a lot of lines: 20200610;My name ;00000001;Name of my company for example; this is the end;01; I need to transform this layout to a positional one. the ...
ianpolitavares's user avatar
3 votes
1 answer
7k views

ZipArchive InvalidDataException: End of Central Directory record could not be found

I am getting the following InvalidDataException thrown when opening an archive made up from a FormFile. System.IO.InvalidDataException: 'End of Central Directory record could not be found.' at ...
Dave New's user avatar
  • 39.6k
0 votes
2 answers
2k views

Write binary asynchronously?

I am trying to make an old method asynchronous. It takes the BLOB from the database and writes it to the disk as a file. However, there is no async version of the write method of the BinaryWriter. ...
KWC's user avatar
  • 147

15 30 50 per page
1
2 3 4 5
10