Click here to Skip to main content
15,904,339 members
Home / Discussions / C#
   

C#

 
GeneralRe: Working with Multiple Forms Pin
hammerstein0511-Dec-08 6:52
hammerstein0511-Dec-08 6:52 
GeneralRe: Working with Multiple Forms Pin
EliottA11-Dec-08 6:54
EliottA11-Dec-08 6:54 
GeneralRe: Working with Multiple Forms Pin
Jim Crafton11-Dec-08 7:14
Jim Crafton11-Dec-08 7:14 
AnswerRe: Working with Multiple Forms Pin
#realJSOP11-Dec-08 4:54
professional#realJSOP11-Dec-08 4:54 
GeneralRe: Working with Multiple Forms Pin
led mike11-Dec-08 5:29
led mike11-Dec-08 5:29 
GeneralRe: Working with Multiple Forms Pin
Ed K11-Dec-08 6:54
Ed K11-Dec-08 6:54 
AnswerRe: Working with Multiple Forms [modified] Pin
Chazzysb11-Dec-08 5:14
Chazzysb11-Dec-08 5:14 
QuestionLeave Event Pin
nagendra.vk11-Dec-08 4:17
nagendra.vk11-Dec-08 4:17 
AnswerRe: Leave Event Pin
Ashfield11-Dec-08 4:46
Ashfield11-Dec-08 4:46 
Question[Message Deleted] Pin
Paul Unsworth11-Dec-08 4:16
Paul Unsworth11-Dec-08 4:16 
AnswerRe: Excel get_Range function in C# Pin
Ashfield11-Dec-08 4:51
Ashfield11-Dec-08 4:51 
GeneralRe: Excel get_Range function in C# Pin
Paul Unsworth11-Dec-08 5:13
Paul Unsworth11-Dec-08 5:13 
Questionwana help in programming(university transport system) Pin
asma zaheer11-Dec-08 3:58
asma zaheer11-Dec-08 3:58 
AnswerRe: wana help in programming(university transport system) PinPopular
#realJSOP11-Dec-08 4:07
professional#realJSOP11-Dec-08 4:07 
GeneralRe: wana help in programming(university transport system) Pin
Ashfield11-Dec-08 4:32
Ashfield11-Dec-08 4:32 
AnswerRe: wana help in programming(university transport system) PinPopular
carbon_golem11-Dec-08 4:10
carbon_golem11-Dec-08 4:10 
GeneralRe: wana help in programming(university transport system) Pin
EliottA11-Dec-08 4:32
EliottA11-Dec-08 4:32 
GeneralRe: wana help in programming(university transport system) Pin
carbon_golem11-Dec-08 4:35
carbon_golem11-Dec-08 4:35 
GeneralRe: wana help in programming(university transport system) Pin
Ashfield11-Dec-08 4:55
Ashfield11-Dec-08 4:55 
GeneralRe: wana help in programming(university transport system) Pin
carbon_golem11-Dec-08 5:15
carbon_golem11-Dec-08 5:15 
GeneralRe: wana help in programming(university transport system) Pin
Christian Graus11-Dec-08 8:07
protectorChristian Graus11-Dec-08 8:07 
AnswerRe: wana help in programming(university transport system) Pin
Nishant Singh11-Dec-08 4:59
Nishant Singh11-Dec-08 4:59 
QuestionRemove data from listbox, then overwrite (save) listbox data in a new create file. Pin
irsalina11-Dec-08 3:42
irsalina11-Dec-08 3:42 
I want to put some data in listBox, then if I want to remove one data, I remove it from the listBox and then overwrite data in listBox to a text file. But it was always failed when it debugged WriteToFile() method below. I dont know why it was failed. It told that "An unhandled exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll"

public void menuItemUn_Click(object sender, EventArgs e)
{
    //Delete Selected Item in Listbox
    listBoxBlockedNumberDD.Items.Remove(listBoxBlockedNumberDD.SelectedItem);
    DeleteFile(Filename);
    WriteToFile();
}

public bool DeleteFile(string Filename)
{
    try
    {
        if (File.Exists(Filename))
        {
            File.Delete(Filename);
            return true;
        }
        else
            return true;
    }
    catch
    {
        return false;
    }
}

public void WriteToFile()
{
        while (listBoxBlockedNumberDD.Items != null)
        {
            using (StreamWriter swb = File.CreateText(Filename))
            {
                <big>swb.WriteLine(listBoxBlockedNumberDD.Items);</big>
                swb.Close();
            }
        }
}

It was always failed in the Big line(WriteLine). I've tried all kinds of Write to file method but there was nothing worked. Could you tell me where is my mistake?

irsalina [student]
AnswerRe: Remove data from listbox, then overwrite (save) listbox data in a new create file. Pin
Nishant Singh11-Dec-08 4:56
Nishant Singh11-Dec-08 4:56 
QuestionRe: Remove data from listbox, then overwrite (save) listbox data in a new create file. Pin
irsalina11-Dec-08 15:55
irsalina11-Dec-08 15:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.