streamwriter

Why does every line in the .txt-file output end with 'System.int32'? C#

你离开我真会死。 提交于 2021-02-11 12:40:17
问题 C#, Console Application, Virtual Studio 2015, Paralelles: Windows 8.1. The code is as follows: class txt_program { public void txt() { /* 0 */ int[] M_array_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* 1 */ int[] M_array_1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* 2 */ int[] M_array_2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // etc. // the M matrix int[][] M = { M_array_0, M_array_1, M_array_2, M_array_3, M_array_4, M_array_5, M_array_6, M_array_7, M_array_8, M_array_9

Why does every line in the .txt-file output end with 'System.int32'? C#

不问归期 提交于 2021-02-11 12:40:17
问题 C#, Console Application, Virtual Studio 2015, Paralelles: Windows 8.1. The code is as follows: class txt_program { public void txt() { /* 0 */ int[] M_array_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* 1 */ int[] M_array_1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* 2 */ int[] M_array_2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // etc. // the M matrix int[][] M = { M_array_0, M_array_1, M_array_2, M_array_3, M_array_4, M_array_5, M_array_6, M_array_7, M_array_8, M_array_9

Modify FileStream

浪子不回头ぞ 提交于 2021-02-09 11:58:47
问题 I'm working now on a class that will allow editing very big text files (4Gb+). Well it may sound a little stupid but I do not understand how I can modify text in a stream. Here is my code: public long Replace(String text1, String text2) { long replaceCount = 0; currentFileStream = File.Open(CurrentFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None); using (BufferedStream bs = new BufferedStream(currentFileStream)) using (StreamReader sr = new StreamReader(bs)) { string line; while

System.IO.StreamWriter doesn't write for entire for loop

别等时光非礼了梦想. 提交于 2021-02-05 06:27:21
问题 I am trying to write a long list of numbers to a file in C# but it keeps stopping before the end of the list. For example the following code: System.IO.StreamWriter file = new System.IO.StreamWriter("D:\\test.txt"); for (int i = 0; i < 500; i++) { file.WriteLine(i); } Leaves me with a text file listing the numbers 0 to 431. Changing 500 to 1000 gets me 0 to 840. It just always seems to stop writing before the loop is finished. Outputing the numbers to console as well as file successfully

Issue writing in the Download directory

两盒软妹~` 提交于 2021-02-05 06:22:26
问题 I'm trying to write this xlsx file in the Download directory of a Samsung Galaxy Tab A 2019 (Android 9.0). If I try to do this on my emulator (Google Pixel C with android 9.0) it works without any problems and I can see the file. If I give the app to my client it gives an error, catches by up by this function: try { importIntoExcel(); DynamicToast.makeSuccess(UserList.this, "Saved!", 2000).show(); b1.setEnabled(true); } catch (IOException e) { DynamicToast.makeError(UserList.this, "Error!",

How to write an .exe file using C# code with StreamWriter?

六眼飞鱼酱① 提交于 2021-01-28 18:44:51
问题 Actually I am copying an exe file over sockets. I am able to copy a text using StreamWriter Class but i used the same code for copying a exe file , it created a exe file with the desired name but I cannot run it. "This app cannot run on your PC". I have Windows 8 x64, that is irrelevant. static void Main(string[] args) { TcpClient tcpclient = new TcpClient(); tcpclient.Connect("localhost", 20209); NetworkStream stm = tcpclient.GetStream(); byte[] buffer = new byte[1024]; var fs = File.Open("F

c# and Unity, update records that have changed to a CSV file

故事扮演 提交于 2020-07-22 05:59:07
问题 I'm trying to work with a CSV file that is essentially a database of records. On load of the game I Read in a record and instantiate a prefab button, one at a time with the correct text from the CSV file. It's not always the case that the index of the button will be the same as the index of the record where I got the information in the CSV file. So far I setup a Save function that I want certain records that have changed based on a tricks "name" field to reflect in the CSV file. What would be

Overwrite contents of ZipArchiveEntry

谁都会走 提交于 2020-07-05 09:18:11
问题 How can I overwrite contents of a ZipArchiveEntry ? Following code using StreamWriter with StringBuilder fails if the new file contents are shorter than the original ones, for example: using System.IO.Compression; //... using (var archive = ZipFile.Open("Test.zip", ZipArchiveMode.Update)) { StringBuilder document; var entry = archive.GetEntry("foo.txt");//entry contents "foobar123" using (StreamReader reader = new StreamReader(entry.Open())) { document = new StringBuilder(reader.ReadToEnd());

Overwrite contents of ZipArchiveEntry

…衆ロ難τιáo~ 提交于 2020-07-05 09:18:00
问题 How can I overwrite contents of a ZipArchiveEntry ? Following code using StreamWriter with StringBuilder fails if the new file contents are shorter than the original ones, for example: using System.IO.Compression; //... using (var archive = ZipFile.Open("Test.zip", ZipArchiveMode.Update)) { StringBuilder document; var entry = archive.GetEntry("foo.txt");//entry contents "foobar123" using (StreamReader reader = new StreamReader(entry.Open())) { document = new StringBuilder(reader.ReadToEnd());

Overwrite contents of ZipArchiveEntry

二次信任 提交于 2020-07-05 09:17:05
问题 How can I overwrite contents of a ZipArchiveEntry ? Following code using StreamWriter with StringBuilder fails if the new file contents are shorter than the original ones, for example: using System.IO.Compression; //... using (var archive = ZipFile.Open("Test.zip", ZipArchiveMode.Update)) { StringBuilder document; var entry = archive.GetEntry("foo.txt");//entry contents "foobar123" using (StreamReader reader = new StreamReader(entry.Open())) { document = new StringBuilder(reader.ReadToEnd());