Open two files as process

How to open 2 files at same time as process?  Do I need 2 process?

ToneElecAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
>>  At the same time is impossible, even with 2 processes.

Really? Then what does this code do?
using (StreamReader reader1 = new StreamReader("file1.txt"))
{
    using (StreamReader reader2 = new StreamReader("file2.txt"))
    {
        // is this not two files open at the same time  ; )
    }
}

Open in new window

0
 
käµfm³d 👽Commented:
What kind of files?
0
 
sergiobg57Commented:
Open two files as process?

At the same time is impossible, even with 2 processes.
What you can do is use 2 threads for that purpose but it will still not be at the same time.

using System.Diagnostics;
System.Diagnostics.Process.Start("cmd");

Open in new window

//use your filename instead of cmd
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sergiobg57Connect With a Mentor Commented:
No, they are being opened consecutively.
One after another.

The way the microprocessor works for parallelism, makes this task impossible.
It's constantly scheduling threads.
One run for sometime, then it's scheduled and another one starts to run for the same amount of time.

That's how it's done.
StreamReader will just open so fast that you might not realize the difference but the difference is still there and if he has any needs to open those files really at the same time, then he will get frustrated.


But i was wrong about 2 processes.
In multi-processor systems it is possible but not likely to happen. =/
0
 
käµfm³d 👽Commented:
My guess would be that the question is not about opening the files at the same exact instance of time, but I could be wrong  = )
0
 
sergiobg57Commented:
That question is a bit confusing. hehe
Let's see which guess is right.
0
All Courses

From novice to tech pro — start learning today.