Questions tagged [writealltext]
29 questions
0
votes
0 answers
Properly editing a text or source file from C#/.NET
The typical way to edit a text or source file from code is to read the file using File.ReadAllLines or File.ReadAllText, make your changes, and then write it out using WriteAllLines or WriteAllText.
However, if you were to open the text file (say…

zumalifeguard
- 8,648
- 5
- 43
- 56
0
votes
1 answer
Parsing a txt file into multiple separate files depending on content
Im having problem getting creating the last file.
I have a tab delimited text file that looks like this.
KABEL Provkanna for Windchill_NWF-TSNM =2212.U001+++-X2 PXC.2400016 =2271.U004+++-X1 Test_Created_in_WT …

Tomas Nordström
- 87
- 7
0
votes
3 answers
WriteAllText, Character Encoding, £ and?
Take the following example:
string testfile1 = Path.Combine(HttpRuntime.AppDomainAppPath, "folder\\" + "test1.txt");
if (!System.IO.File.Exists(testfile1))
{
System.IO.File.WriteAllText(testfile1, "£100", System.Text.Encoding.ASCII);
}
string…

Captain_Planet
- 1,228
- 1
- 12
- 28
0
votes
1 answer
Same File operation not permitted. Access to path denied, Silverlight 5.0
I am working with a silverlight application, File.WriteAllText is giving File operation not permitted when trying to write to local desktop. Access to path exception.
This code always works on local desktop but, is giving error when code is deployed…

Agile
- 39
- 6
0
votes
3 answers
C# Write ComboBox items on separate lines
I thought it would just be as simple as
StringBuilder buildStrings = new StringBuilder();
foreach (string day in weeklyPlan.Items)
{
buildStrings.Append(day);
buildStrings.Append("\n");
}
string pathing =…

HoneyPunch
- 3
- 2
0
votes
3 answers
How To Use "{0}" In A File.WriteAllLines?
So, I am attempting to create multiple files with different names. I am trying to change one number in the file name like this, but it won't let me use "{0}" to insert a string.
String value = "1";
foreach (var message in…

Cratherton
- 17
- 1
- 9
0
votes
0 answers
File.WriteAllText in windows service
It is possible to use File.WriteAllText in the windows service ?? now how to add them to the timer for checking every minute, I'd like to write text to a file, but unfortunately it did not work ..
void _zegar_timer_Elapsed(object sender,…

mariusz695
- 47
- 6
0
votes
2 answers
How to optimize C# concurrent file write performance
I'm trying to optimize the performance of creating a lot of small files to a SSD disk.
ConcurrentBag cb = new ConcurrentBag();
cb.AsParallel().ForAll(fa => File.WriteAllText(fa[0], fa[1]));
Total count of the…

BigChief
- 1,413
- 4
- 24
- 37
0
votes
1 answer
Remove particular line in a .txt file and replace with new line vb.net
I've seen this question on here a few times but I can't seem to find the right answer. I currently have a Windows Form Application I'm writing in VB that creates player profiles (this is a school project). On the 'Registration' page I take in the…

j_fulch
- 125
- 2
- 13
0
votes
0 answers
writealltext vb.net web form
How to: Write Text to Files in Visual Basic
I am trying to use this procedure to export data from a datatable into a csv file. I have got the data from the table ready in a string and am trying to use the following code to write in to a file (I did…

Barry
- 63
- 7
0
votes
3 answers
How to determine the smaller time C#
I require a way to store the smallest time to replace any existing, but currently what I have tried [below] doesn't work and may sometimes say that 2:38.4 is smaller than 2:20.1.
In the text file
88:88:8
In the form 3 text…

Alias Fakkenäme
- 13
- 4
0
votes
3 answers
Replacing Text in File
I wrote a method that will go through all text files, replace text, and update a textbox with said changes. It works after I run it a first time, but subsequent executions seem to infer that the files weren't changed the first time.
private void…

Demasterpl
- 2,103
- 5
- 24
- 32
-1
votes
1 answer
C#: Replace a string in a line of text
I'm trying to replace specific strings in several files. These files are read from a specific source. What I want is to read these files line by line, find my desired strings in each line and replace them by other strings.
So far I've come up with…

Vahid
- 5,144
- 13
- 70
- 146
-2
votes
2 answers
File is being used by another process while using WriteAllText in c#
I am checking file is present if specified location and if so I am replacing single quote by '. For this I am using WriteAllText method. For my knowledge WriteAllText will be used to Create file and write the text and close it, target file is…

Shesha
- 1,857
- 6
- 21
- 28