Is it possible to read and write to a file at the same time and display the results in a RichTextBox?

Hi All,
I have a purpose in winforms to have a "notepad like" editor that saves what ever i type to a file on the hard drive and reads from based. 
So what i have is a tab with a richtextbox docked to fill. I would like to have that richtextbox read from a file on the hard drive, then save the changes i type when i either click off the tab or live if possible.
I wills state that i am fairly new to the c# game and if this is possible and someone could post an example that would be awesome and totally appreciated.
Thanks,
jAC

For those that are looking for the solution I went with here are the details
Reading the file:
// Wish List Section
wishListRichTextBox.ResetText();
string wlFolder = Application.StartupPath + "\\wishLists\\";
string wlPath = wlFolder + selectedProduct + ".rtf";
// Read from the text file and out put the results
try
{ // create directory if it does not exist
if (!Directory.Exists(wlFolder))
Directory.CreateDirectory(wlFolder);
} // create file if it does not exist
if (!File.Exists(wlPath))
File.Create(wlPath).Dispose();
var iStream = new FileStream(wlPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var sr = new System.IO.StreamReader(iStream);
var readData = sr.ReadToEnd();
wishListRichTextBox.Text = readData;
sr.Close();
// If the read fails then output the error message in the same section
catch (Exception ex)
wishListRichTextBox.Text = "Error: " + ex.Message;
Writing the file:
private void wishlistTabChanged(object sender, EventArgs e)
if(menuTabControl.SelectedTab != wishListTab){
if (productComboBox.SelectedIndex >= 0)
try
string wlFolder = Application.StartupPath + "\\wishLists\\";
string wlPath = wlFolder + productComboBox.SelectedItem + ".rtf";
var oStream = new FileStream(wlPath, FileMode.Open, FileAccess.Write, FileShare.Read);
oStream.SetLength(0);
var sw = new System.IO.StreamWriter(oStream);
sw.WriteLine(wishListRichTextBox.Text);
sw.Close();
catch (Exception ex)
MessageBox.Show("Wish list for " + productComboBox.Text + " save failed. \n\nError: " +
ex, "Wish List Save Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
I mainly used Ammar.Zaied thought
process on this. Thanks to everyone though, as you all pointed me in the right direction

Similar Messages

  • Generat two signals at the same time and reading voltage

    Hii
    i have try to generate two signals at the same time and read voltage from another port on the board(not have to be at the same time), i have not alot of expriens in labview
    and i based my code of example(http://zone.ni.com/devzone/cda/epd/p/id/5197) from yours site and try to suit to my needs
    now my problem is when i generat the 2 signals(that work perfect) i canot read voltage from another port on my CB-68LP
    i can not find the problem  and make it over i hope there is away to figer out and fix it.
    i have two cards 6229, and two CB-68LP board.
    labview 8.5.
    my code is look like this - http://img142.imageshack.us/my.php?image=scrennshot2no2.png
    (this works perfect).
    and this is my code after suit to my need - http://img183.imageshack.us/my.php?image=scrennshotfl5.png,there is  error exception at  the right side.
    the exception-
    Possible reason(s):
    Specified route cannot be satisfied, because it requires resources that are currently in use by another route.
    Property: RefClk.Src
    Source Device: Dev1
    Source Terminal: 10MHzRefClock
    Required Resources in Use by
    Task Name: _unnamedTask<0>
    Source Device: Dev1
    Source Terminal: None
    Destination Device: Dev1
    Destination Terminal: RefClock
    Task Name: _unnamedTask<1>
    eyal

    sorry...
    The AO tasks is very important they will be synchronize ,it is very importent the two tasks will start at the same time
    and after it run at synchronize mode i will need to make reading of voltage
    i gust try to make simulation of machin (i give that machin AO and reading from it voltage that all)
    first of all i make the two signals(synchronize signals).
    and after it i will need to reading voltage.
    i can make two signals synchronize together.
    i can make reading voltage
    but i can't make two signals synchronize together with reading voltage
    it throw to me this error message.
    i am looking for away to figer this out.
    thank's for any help 
    eyal
    Attachments:
    test11.vi ‏130 KB

  • The ipad won't sync some photos, saying the file can't be read by the ipad, however it will sync some photos taken at the same time which are the same size and file type.  Why does it reject some and accept others?

    The ipad won't sync some photos, saying the file can't be read by the ipad, however it will sync some photos taken at the same time which are the same size and file type.  Why does it reject some and accept others?

    Hi there. I'm having the same problem: my iPad won't import some photos from a folder, saying that they can't be read. They are all JPEGS and some photos taken at the same time have synched fine, but out of a folder with 200 photos, it only lets me synch 37. I'm synching albums created via Photoshop Elements 6, which has worked fine until now.
    I've tried deleting all photos and re-synching, and have also deleted the iPod Photo Cache, but it hasn't made a difference.
    The iPad auto-updated to the latest version of iTunes, so maybe that's what's causing it?
    Any advice gratefully received!

  • How can I do to acquire and save date in the same time and in the same file when I run continual my VI without interrupti​on.

    I've attached a VI that I am using to acquire amplitude from Spectrum analyzerse. I tried to connect amplitude ouput to the VI Write Characters To File.vi and Write to Spreadsheet File.vi. Unfortunately when I run continual this VI without interruption, labview ask me many time to enter a new file name to save a new value.
    So, How can I do to aquire and save date in the same time and in the same file when I run continual my VI for example during 10 min.
    Thank you in advance.
    Regards,
    Attachments:
    HP8563E_Query_Amplitude.vi ‏37 KB

    Hi,
    Your VI does work perfectly. Unfortunately this not what I want to do. I've made error in my last comment. I am so sorry for this.
    So I explain to you again what I want to do exactly. I want to acquire amplitude along road by my vehicle. I want to use wheel signal coming from vehicle to measure distance along road. Then I acquire 1 amplitude each 60 inches from spectrum analyzer.
    I acquire from PC parallel port a coded wheel signal coming from vehicle (each period of the signal corresponds to 12 Inches). Figure attached shows the numeric signal coming from vehicle, and the corresponding values “120” and “88” that I can read from In Port vi.
    So I want to acquire 1 time amplitude from spectrum analyser each 5
    period of the signal that I am acquiring from parallel port.
    So fist I have to find how can I count the number of period from reading the values “120” and “88” that I am acquiring from In Port (I don’t know the way to count a number of period from reading values “120” and “88”).
    Here is a new algorithm.
    1) i=0 (counter: number of period)
    2) I read value from In Port
    3) If I acquire a period
    i= i+1 (another period)
    4) If i is multiple of 5 (If I read 5 period)
    acquire 1 time amplitude and write to the same
    file this amplitude and the corresponding distance
    Distance = 12*i). Remember each period of signal
    Corresponds to 12 Inches).i has to take these
    values: 5,10,15,20,25,35,40,45,50,55,60............
    5) Back to 2 if not stop.
    Thank you very much for helping me.
    Regards,
    Attachments:
    Acquire_Amplitude_00.vi ‏59 KB
    Figure_Algorithm.doc ‏26 KB

  • Hello i hav an ipad mini and i was in the middle of the ios 8 update and i held the sleep and home button at the same time to cancel the update and now it wants me to connect to itunes i dont no how to do that can someone pleaze help me

    hello i hav an ipad mini and i was in the middle of the ios 8 update and i held the sleep and home button at the same time to cancel the update and now it wants me to connect to itunes i dont no how to do that can someone pleaze help me?

    RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port.
    DO NOT RELEASE BUTTON until you see picture of iTunes and plug
    5. Release Home button.
    ON COMPUTER
    6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
    7. Select "Restore iPad"...
    Note:
    1. Data will be lost if you do not have backup
    2. You must follow step 1 to step 4 VERY CLOSELY.
    3. Repeat the process if necessary.

  • Can you use apple tv to play a movie on your tv (say for kids to watch) and use your mac book at the same time to browse the internet ???

    Using a mac book pro !
    Can you use apple tv to play a movie on your tv (say for kids to watch) and use your mac book at the same time to browse the internet ???

    Good question bigboggerchoot.  I also would like to know the answer to this.

  • How do I make a 20 X 30 print with layers of 16 X 20, 12 X 18, 11 X 14, 8 X 12, 8 X 10, 5 X 7 and 4 X 6 of the same image to display the different sizes available to someone?  Using Elements 13 with Windows 8.1

    How do I make a 20 X 30 print with layers of 16 X 20, 12 X 18, 11 X 14, 8 X 12, 8 X 10, 5 X 7 and 4 X 6 of the same image to display the different sizes available to someone?  Using Elements 13 with Windows 8.1
    A senior citizen needs some help.
    Thanks

    Saving each image as different size - is it an option for you?  I would save images with their name as: 20x30.png, 16x20.png etc etc.
    Or explain whether you want these in a webpage  in which case only one image is necessary and different sizes are displayed with good CSS code.  this is question for Dreamweaver forum if this is what you want.

  • Several of us have a iPhone 6s and are having trouble with hearing and speaking at the same time when using the phone. ? The speakers seem to be too far apart? Are others having this issue? Solutions?

    Several of us have a iPhone 6plus and are having trouble with hearing and speaking at the same time when using the phone. ? The speakers seem to be too far apart? Are others having this issue? Solutions?

    Not having the problem, don't personally know anyone who is.

  • For the past month, I've had an echo of my voice while I'm talking on my phone.  It's very annoying and sounds like multiple people are speaking at the same time and it's only me.  Anyone know what's wrong?

    For the past month, I've had an echo of my voice while I'm talking on my phone.  It's very annoying and sounds like multiple people are speaking at the same time and it's only me.  Anyone know what's wrong?

    For the past month, I've had an echo of my voice while I'm talking on my phone.  It's very annoying and sounds like multiple people are speaking at the same time and it's only me.  Anyone know what's wrong?

  • Whenever I open a new tab a new window is also opening at the same time, and when i close that tab thet window is also closing. what to do?

    Whenever I open a new tab a new window is also opening at the same time, and when i close that tab that window is also closing. what to do?

    Swarnava, thank you very much! that did it and I am Bing-less . . . OH HAPPY DAY!! WOOHOO!!!! thank you, thank you, thank you!

  • I-phone shuts off, I have to hold the home and power button at the same time to get the icon to show up.  Then have to hold the home button.  I'm restoring my phone multiple times a day just to get it to work. help!

    i-phone shuts off, I have to hold the home and power button at the same time to get the icon to show up.  Then have to hold the home button.  I'm restoring my phone multiple times a day just to get it to work. help!

    Are you restoring as new?

  • Can anybody explain how to print multiple copies of different documents at the same time as at the moment I have to open each individually and press print

    Can anybody explain how to print multiple copies of different documents at the same time as at the moment I have to open each individually and press print

    is this a windows in bootcamp question ?

  • How do I remove the application from your iPad at the same time and with the clouds?

    Hello,
    how can I remove the application from your iPad at the same time and with the clouds?
    I know you press the app icon until it starts shaking, then press the black cross in the upper left corner. This will remove it.
    But still I will come in to the store as a bookmark Purchated I see it with the symbol of a cloud. And I would like to remove it for good. Under iOS 5.1.1 somehow I managed to do that (at least hide it). In iOS 6 I can not do that.
    I greet

    The only transition you can add this way is default cross dissolve. If the images are in the timeline, move the playhead to the beginning of the images, select them all, and drag from the timeline to the canvas to overwrite with transition.

  • My newer IPhone gets a weaker cell signal at the same time and place as my wife's older one. Help

    My newer IPhone gets a weaker cell phone signal at the same time and place as my wife's older IPhone. Help!

    What is the signal the difference?
    Follow this guide and record the numbers you see...
    http://lifehacker.com/5929546/see-the-actual-signal-strength-on-your-iphone-with -this-quick-tweak
    If the difference is within ~10db there's not much to worry about.
    Now if you see -130 and -80 that is an issue. (talk to your carrier)
    But if you see -60 and -75, both phones are operating normally.
    What are the iPhones in question?
    Are you both on the same network? (what network(s) are you on?)
    What data connection is available on each phone? (3G/4G/LTE)
    Are the iOS and Carrier settings up-to-date?

  • Is there an issue with the hitachi hard drives in the MacBook Pro's ?  Got a 15 inch and a 13 inch at the same time and both drives have failed in under two years. I have heard from a few other people with same issue.

    Is there an issue with the hitachi hard drives in the MacBook Pro's ?  Got a 15 inch and a 13 inch at the same time and both drives have failed in under two years. I have heard from a few other people with same issue. Other drive I have had have lasted at least 5 or more years.

    there is a dylib you can put in the springboard if jailbroken but if not you have to find an apple store

  • How to open 2 playlist at the same time and have them in two diferents windows?

    until iTunes 10 i can open more than one playlist at the same time, and have this playlist in diferents windos but since 11 i cannot do it anymore.. is anoying if i need to fast switc music froms playlists.. so it become usseless...
    i think the aim of the previous itunes (before 10) it was to give a service of arranging librerys of musics.. but now, it becomes a sell party program...
    and only to you to know, if i dont put my credit card on my account i cannot even buy FREE programs on appstore...
    thats bad... very bad..
    if you need some tips how to do it proprerly here you got one..
    if is not broken... dont fix it...
    now i have my iphone 6, my ipad and the iphone of my wife, but i have itunes 10 because is the one who have the multi windows possibilities.. and now i cannot sync the devices..
    thats very bad..
    i hope you can help me...
    if you dont understand my problem i can show you via video..
    thanks

    You could create an applescript to do it.
    tell application "Dreamweaver's Full Name"
    activate
    end tell
    tell application "BBEdit's Full Name"
    activate
    end tell
    tell application "Acrobat's Full Name"
    activate
    end tell
    Replace the quoted text (leaving the quotes) with the full name of the application, and save the applescript as an application bundle, and put it in your dock.
    NOTE: You may have to put the full path to the application for it to work (I.E. /Applications/Dreamweaver.app). If you do, encase the full path in quotes.
    Good luck!
    Message was edited by: joshz

Maybe you are looking for

  • Log Directories in Oracle 10g RAC environment

    Hi all, Would you please tell me in which directories, the following log files will be created, in a Oracle 10g RAC enviroment. evmd.log crsd.log ocssd.log Best Regards, Narayan

  • Bex Issue Query

    Hello, I have a query about Bex.  I have 2 Bex Queries with different Keyfigures on different providers. Query 1: Customer     Material     Plant     Quantity Sold Query 2: Customer Material Plant Quantity Available This is what i want to do.  Basica

  • After IronPort upgrade - GATEWAY_TIMEOUT,

    Hi We have a rising issue where our users do not reach various websites without any apparent reason. The Policy trace suggests that everything is ok, but they end up getting a GATEWAY_TIMEOUT, in their web browser whenever they try. We recently upgra

  • ISA 500

    Is there a possiility to script the Firewall-Configuration for Backup or for editing the configuration and restoring it to get productive?

  • Cannot load custom Swing component

    Hi, I have an existing desktop application where there are quite a few custom Swing components in use. There's not been an issue before with these components (past 2 yrs).... until today :-). I opened my IDE (Java Studio Enterprise 8.1) and began wor