streamwriter Questions
2
Solved
Documentation says FileMode.OpenOrCreate "specifies that the operating system should open a file if it exists; otherwise, a new file should be created", which sounds like it will open the...
Careerism asked 25/8, 2018 at 19:1
7
Solved
Classes such as Stream, StreamReader, StreamWriter etc implements IDisposable interface. That means, we can call Dispose() method on objects of these classes. They've also defined a public method c...
Conflagrant asked 23/9, 2011 at 6:5
7
Solved
Why using (var sw = new StreamWriter(ms)) returns Cannot access a closed Stream exception while the MemoryStream is on top of this code?
using (var ms = new MemoryStream())
{
using (var sw = new S...
Sukiyaki asked 7/6, 2012 at 15:10
5
Solved
I'm using the C# StreamWritier class. Questions:
How can I make a file read-only, so that no one can delete or write to it?
How can I make a hidden file?
I'm creating the file like so:
priva...
Mckissick asked 2/8, 2012 at 12:57
5
Solved
I have a created a StringBuilder of length "132370292", when I try to get the string using the ToString() method it throws OutOfMemoryException.
StringBuilder SB = new StringBuilder();
for(int i ...
Suppository asked 29/7, 2014 at 7:56
8
Solved
I'm working on a application which will export my DataGridView called scannerDataGridView to a csv file.
Found some example code to do this, but can't get it working. Btw my datagrid isn't databou...
Ezar asked 30/3, 2012 at 13:18
3
Solved
I suppose my title isn't that clear.
I'll try to explain:
I can write and read a file using a FileStream
FileStream fs = new FileStream("C:\\Users\\Public\\text.txt", FileMode.OpenOrCreate, File...
Dc asked 27/11, 2011 at 19:35
6
Solved
I can't read those special characters
I tried like this
1st way #
string xmlFile = File.ReadAllText(fileName);
2nd way #
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Rea...
Ced asked 11/11, 2011 at 3:33
9
Solved
I need to get my code to read if file doesnt exist create else append. Right now it is reading if it does exist create and append. Here is the code:
if (File.Exists(path))
{
using (StreamWriter s...
Actino asked 30/4, 2012 at 11:37
3
Solved
I am using CsvHelper I need to wrap all values with quotes.
Is that possible?
Data = is a List
using (StreamWriter textWriter = new StreamWriter(path))
{
textWriter.BaseStream.Write(p, 0, p.Leng...
Lipkin asked 1/1, 2019 at 13:38
3
I can't rewrite a file that I am getting from a binary buffer, I have checked with the original file and all bytes are the same.
This is the file create from NodeJS:
# hd test.txt | head
00000000 4...
Phocis asked 12/10, 2012 at 22:42
7
Solved
What is the fastest way to export DataGridView rows in the range of 460328 - 800328 to Excel or into an SQL Server database table with out using Microsoft office interop as interop is quite slow an...
Stith asked 31/7, 2012 at 14:28
7
Solved
I'm creating a StreamWriter using a relative path. But the file doesn't appear. To troubleshoot, I want to check that the full path is what I'm expecting. So having a StreamWriter instance, how can...
Ker asked 7/5, 2012 at 13:51
5
I need to use StreamReader to read a .txt file on a console application, then create a new file or backup with a different name but same content. The problem is i cant figure out how to use the con...
Bonina asked 5/8, 2015 at 1:14
7
i want clear text file contet with this method
private void writeTextFile(string filePath, string text)
{
if (!File.Exists(filePath))
{
File.Create(filePath).Close();
}
using (StreamWriter t...
Hiltner asked 14/2, 2014 at 22:20
11
Solved
I want to append lines to my file. I am using a StreamWriter:
StreamWriter file2 = new StreamWriter(@"c:\file.txt");
file2.WriteLine(someString);
file2.Close();
The output of my file should be s...
Sills asked 5/9, 2011 at 9:32
3
I am writing some test application to write some text into a text file using StreamWriter. While executing the WriteLine method the system shuts down abruptly. After rebooting the machine I have ob...
Gangling asked 6/6, 2012 at 11:49
4
Solved
I want to write something to a file. I found this code:
private void writeToFile(String data) {
try {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(context.openFileOutput("conf...
Stringendo asked 18/2, 2016 at 12:47
5
Solved
I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:
if (dr == DialogResult.OK)
{
StreamWriter sw = new Str...
Firedog asked 16/11, 2011 at 12:5
3
Solved
My program was practice for me, however, when I try to write all the directories it found, it crashes.
I tried the following:
Having it write to a file stream instead of the file itself
using F...
Ptarmigan asked 18/11, 2013 at 4:24
6
Solved
I have this code:
string s = "آ";
StreamWriter writer = new StreamWriter("a.txt", false, Encoding.UTF8);
writer.WriteLine(s);
but when I run it I can't see any "آ" in a.txt!! There isn't any str...
Suomi asked 19/11, 2011 at 19:45
3
Solved
I'm trying to write a tool in C# to help QA some network issues, and am running into a problem. The program is supposed to send a query in JSON format to the server every second.
Currently, it wor...
Piacular asked 21/8, 2015 at 19:8
4
Solved
I created a class with the responsibility to generate a text file where each line represents the information of an object of 'MyDataClass' class. Below is a simplification of my code:
public class...
Kujawa asked 17/4, 2015 at 17:23
6
My C# winforms 4.0 application has been using a thread-safe streamwriter to do internal, debug logging information. When my app opens, it deletes the file, and recreates it. When the app closes, it...
Levine asked 5/6, 2013 at 20:59
4
Solved
I just found a few answers for this, but found them all horribly long with lots of iterations, so I came up with my own solution:
Convert table to string:
string myTableAsString =
String.Join(...
Enrica asked 1/6, 2015 at 20:27
1 Next >
© 2022 - 2025 — McMap. All rights reserved.