C
C#3mo ago
The Father

File stream Speed Question

alright so i want to make a program that takes all of the c# files in a directory, copies all of their content to that single file and trim the using statements
25 Replies
The Father
The FatherOP3mo ago
note i haven't used filestream in c# before anyways i want to which method would be faster for copying the content: - copying all of the lines in one file to a single array/List, and doing that for each .cs file in the directory, or - directly copying each line from the original file to the output file while i'm iterating through each file i would assume the latter would be faster or both methods would be the same speed
Angius
Angius3mo ago
That's one weird thing you're trying to do there, gotta say
The Father
The FatherOP3mo ago
it's for school since i can't run .net or anything on the chromebooks and i want to use an online compiler
Angius
Angius3mo ago
If I were to do concatenating files, I'd probably loop over them, read each individually, and keep appending them to a file
The Father
The FatherOP3mo ago
so read a line, append it to the file and repeat for each line of each file?
Angius
Angius3mo ago
No Read a file, append it to the end
The Father
The FatherOP3mo ago
mm so you can just copy the content of the whole file?
Angius
Angius3mo ago
Sure
The Father
The FatherOP3mo ago
mm alright thanks
Angius
Angius3mo ago
Also, you can install VS Code on a Chromebook, just gotta enable Linux layer Alternatively, Github has free codespaces
The Father
The FatherOP3mo ago
linux is blocked what is a codespace
Angius
Angius3mo ago
A remote virtual machine with VS Code running in the browser connected to it
The Father
The FatherOP3mo ago
oh fuck yeah it seems like it might work so it would work with VS solutions then?
Angius
Angius3mo ago
Alternatively, take it up with your school. If they require you to write good and proper C# on a Chromebook, they better make it work for you Well, depends Is it .NET Framework or .NET? If the former, it's Windows-only
The Father
The FatherOP3mo ago
.NET i'm sure yeah
Angius
Angius3mo ago
If the latter, then yes
The Father
The FatherOP3mo ago
i don't even know the difference other than that .net framework is windows only i'm doing c# for fun but i wish i knew how to do that @ZZZZZZZZZZZZZZZZZZZZZZZZZ also is it possible for a using statement to have a string in it
Angius
Angius3mo ago
Wym?
The Father
The FatherOP3mo ago
it likely won't be a problem but just in case using "this thing" if not then i only have to parse it with consideration for comments since the symbols can't have backslashes
Angius
Angius3mo ago
That's not valid C#
The Father
The FatherOP3mo ago
ok good
Angius
Angius3mo ago
using System.Text.Json; // namespace import
using static System.Console; // static class import
using Foo = (int a, int b); // type alias

using var d = SomethingDisposable(); // using disposables
using (var d = SomethingDisposable()) // another way
{
// ...
}
using System.Text.Json; // namespace import
using static System.Console; // static class import
using Foo = (int a, int b); // type alias

using var d = SomethingDisposable(); // using disposables
using (var d = SomethingDisposable()) // another way
{
// ...
}
all the valid situations where using works
The Father
The FatherOP3mo ago
alright thanks wait so what would you use this for
using var d = SomethingDisposable();
using var d = SomethingDisposable();
and would this free d immediately after exiting the scope?
using (var d = SomethingDisposable()) // another way
{
// ...
}
using (var d = SomethingDisposable()) // another way
{
// ...
}
that would explain why you use it for filestream
Angius
Angius3mo ago
With the using statement, the resource is freed at the end of the scope With the using block, at the end of the block
The Father
The FatherOP3mo ago
alright thanks
Want results from more Discord servers?
Add your server