Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Tony4966

@Tony4966
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Read and Write a file at the same time?
    T Tony4966

    Thanks so much for so many excellent replies. I appreicate all of them I finally 'have to' give up this 'bad' design because I can get it working but it's very messy and probably not worthwhile spending too much time on it. Just a quick note; I get writer part working like this, which is enssentially the same as suggested.

    string path = @"C:\Documents and Settings\";

    string filename = "testernew1.txt";

    var fi = File.Open(path + filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
    var sw = new StreamWriter(fi);
    for (int j = 10; j < 0; j--)
    sw.Write(j);
    sw.Flush();
    fi.Flush();
    sw.Close();
    fi.Close();

    Apparently, the reader part is very simliar. I am not familiar with message queque so I am going to look into it; also someone told me that it also be done by using remote charting which I assume is more complicated than message quque? Anyway, it would be great if someone can show some examples of either using message queue or remote charting. Thanks again for all the replies!

    C# csharp question

  • Read and Write a file at the same time?
    T Tony4966

    You are right. This is probably not a good design but I just want to get this working as quickly as possible and it is just a short term solution. So please can you be a little bit more specific about how exactly I let the program that writes into the file allow other programs to read the file at the same time? A quick example of would be

    string path = @"C:\Documents and Settings\";

            string filename = "tester.csv";
    
            TextWriter writer = new StreamWriter(path + filename, false);
            
            for (int j = 0; j < 10; j++)
                writer.WriteLine("{0}, {1}", j,2 \* j);
    

    Many thanks indeed.

    C# csharp question

  • Read and Write a file at the same time?
    T Tony4966

    Hi Is there a way of writing and reading a csv file from C# at the same time? I mean I have two separated projects; one keeps writing data into a csv file and the other one is to read the data from the same csv that is also being written. When I tried this, it always says the file can't be accessed because it's being used by another process. Is there anyway of getting around this? Many thanks indeed.

    C# csharp question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups