Skip to main content

All Questions

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
-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
0 votes
0 answers
40 views

Should i close each substreams of filestream or closing filestream will be enought?

I readed a lot of topics about C# streams, but did not find my situation. For learing purpose i did list-file json-bd like: public sealed class JSONBD<T> : IDisposable { private FileStream ...
VladisS's user avatar
  • 67
1 vote
3 answers
431 views

C# Reuse StreamWriter or FileStream but change destination file

A little background... Everything I'm about to describe up to my implementation of the StreamWriter is business processes which I cannot change. Every month I pull around 200 different tables of data ...
TheFuzzyGiggler's user avatar
-1 votes
1 answer
520 views

Could not found the path for create and write file

My code is after run on Azure it say: { "Message": "Cannot create 'D:\\home\\site\\wwwroot\\DataFile' because a file or directory with the same name already exists." } how to ...
Kelvin's user avatar
  • 199
1 vote
1 answer
601 views

Why is c# creating a file before any file stream is created?

Background: I am creating an avaloniaUI project and in it I have a json config with a class that serializes and deserializes it on initialization and editing. If the file can't be found on ...
Artemis Venatrix's user avatar
0 votes
2 answers
128 views

I'm trying to simply append two different data types into my xml file and read them again, but I am getting an error

I'm using Winforms and I get the following error when I press the load button after having hit the save button: InvalidOperationException: was not expected. Here is my code: private void save_Click(...
dutoit077's user avatar
0 votes
2 answers
332 views

How to delete the line at the end of the text file in vb.net?

How do I ensure that I don't have an extra line at the end of the file? It's a bit special, I divide the line into three places which are respectively 17, 90 and 120 bytes (total: 227 bytes). I tried ...
claudebl's user avatar
0 votes
0 answers
69 views

C# StreamWriter, FileStream write

I'm working on Huffman algorithm right now and I need to write into output file some information (in order to decode what I've got): dictionary (character and its code), number of added zeros (count) ...
Elizabeth Grant's user avatar
1 vote
2 answers
6k views

FileStream vs StreamReader and StreamWriter - what's the difference? [duplicate]

What functionality is allowed via StreamReader and StreamWriter when working with files which can't be done via FileStream, or vice versa? I checked the docs and they both have read / write options, ...
Aviv Vetaro's user avatar
1 vote
1 answer
998 views

Using StreamWriter: What is quicker writting one big string or many smaller pieces?

I am generating an HTML output File in C#, though the speed performance for 60 Mb files seems to be impossibly long. It takes 20 minutes to generate the file, which is a very slow process. Previously ...
YoungDad's user avatar
  • 825
0 votes
0 answers
89 views

Is it ok to handle text file by Streamreader & StreamWriter without prior use of FileStream?

Is it still good practise to handle the text file withot using FileStream like in an example below: StreamWriter sw2 = new StreamWriter(filePath); sw2.WriteLine("Some text&...
kalka79's user avatar
  • 11
0 votes
2 answers
64 views

Generated .txt file doesn't show up

So, I'm tryng to generating a txt file with a matrix of 0 and 1, where all the borders are 0 and the body of the matrix is randomly filled with both values. It should be a bitMap where 0 is an ...
Peru's user avatar
  • 45
0 votes
1 answer
39 views

StreamWriter don't writing any text to file

I wrote some code, which should write to file some text: private static FileStream CreateFile() { string _fileName = "znaki.txt"; if(File.Exists(_fileName)) ...
user avatar
1 vote
6 answers
2k views

how to write file using streamwriter/textwriter/File?

I am able to write file when program is restarted(as it is always the first attempt of writing) but during the same execution it only works for the first time then after that it throws an exception ...
Aditya's user avatar
  • 65

15 30 50 per page
1
2 3 4 5
7