Click here to Skip to main content
15,887,585 members
Home / Discussions / C#
   

C#

 
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 
QuestionQuestion about dates Pin
harcaype11-Dec-08 3:36
harcaype11-Dec-08 3:36 
AnswerRe: Question about dates Pin
Simon P Stevens11-Dec-08 3:51
Simon P Stevens11-Dec-08 3:51 
RantRe: Question about dates Pin
harcaype11-Dec-08 4:12
harcaype11-Dec-08 4:12 
GeneralRe: Question about dates Pin
Simon P Stevens11-Dec-08 4:56
Simon P Stevens11-Dec-08 4:56 
GeneralRe: Question about dates Pin
Mirko198011-Dec-08 4:57
Mirko198011-Dec-08 4:57 
QuestionUpdate changes made in gridview in DataTable Pin
Yustme11-Dec-08 3:16
Yustme11-Dec-08 3:16 
AnswerRe: Update changes made in gridview in DataTable Pin
Dave Kreskowiak11-Dec-08 4:27
mveDave Kreskowiak11-Dec-08 4:27 
GeneralRe: Update changes made in gridview in DataTable Pin
Yustme11-Dec-08 4:38
Yustme11-Dec-08 4:38 
GeneralRe: Update changes made in gridview in DataTable Pin
Dave Kreskowiak11-Dec-08 6:24
mveDave Kreskowiak11-Dec-08 6:24 
GeneralRe: Update changes made in gridview in DataTable Pin
Yustme11-Dec-08 10:34
Yustme11-Dec-08 10:34 
GeneralRe: Update changes made in gridview in DataTable Pin
Dave Kreskowiak11-Dec-08 12:31
mveDave Kreskowiak11-Dec-08 12:31 
GeneralRe: Update changes made in gridview in DataTable [modified] Pin
Yustme11-Dec-08 20:22
Yustme11-Dec-08 20:22 
QuestionReport viewer Pin
Neo Andreson11-Dec-08 2:52
Neo Andreson11-Dec-08 2:52 
QuestionList items [modified] Pin
nlowdon11-Dec-08 2:45
nlowdon11-Dec-08 2:45 
AnswerRe: List items Pin
Simon P Stevens11-Dec-08 2:55
Simon P Stevens11-Dec-08 2: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.