Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to know that Datagrid values have been modified Pin
Tamimi - Code17-Sep-06 20:56
Tamimi - Code17-Sep-06 20:56 
Questionhow to delete a row in database Pin
faladrim17-Sep-06 20:29
faladrim17-Sep-06 20:29 
AnswerRe: how to delete a row in database Pin
Hamid_RT18-Sep-06 9:30
Hamid_RT18-Sep-06 9:30 
QuestionAdding Child Controls to UserControl at design time Pin
TofuBug2417-Sep-06 19:34
TofuBug2417-Sep-06 19:34 
AnswerRe: Adding Child Controls to UserControl at design time Pin
Martin#17-Sep-06 21:22
Martin#17-Sep-06 21:22 
GeneralRe: Adding Child Controls to UserControl at design time Pin
TofuBug2418-Sep-06 1:22
TofuBug2418-Sep-06 1:22 
QuestionDeleting a file Pin
saqib8217-Sep-06 19:27
saqib8217-Sep-06 19:27 
AnswerRe: Deleting a file Pin
Jakob Farian Krarup17-Sep-06 19:54
Jakob Farian Krarup17-Sep-06 19:54 
You can delete all files in the same way:

System.IO.File.Delete("path");

When you ask specifically about files created by a FileStream, then I guess you have a problem with the file being locked.
This can happen if an exception occurs while you are working with the filestream, or if you haven't released the file from the stream again before deleting it.

You should always use Structured Exception Handling when using I/O operations in code:

using System;
using System.IO;

namespace Testing

{
  public class Test
  {

    public static void Main()
    {

      FileStream fs = null;
      try
      {
        fs = new FileStream(@"c:\test.txt", FileMode.Create);
        byte[] content =  new System.Text.UTF8Encoding(true).GetBytes("Hi there!");
        fs.Write(content, 0, 9);
      }
      catch (IOException ioe)
      {
        Console.WriteLine("Something happened");
        if(fs != null)
          fs.Close();
      }
    }
  }
}


In this case the file will always be closed, and you should be able to delete it.




Kind regards - Jakob Cool | :cool:
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!

10 kinds of people in the world:
- Those who understand binary
- Those who don't

GeneralRe: Deleting a file Pin
Christian Graus17-Sep-06 20:22
protectorChristian Graus17-Sep-06 20:22 
GeneralRe: Deleting a file Pin
Jakob Farian Krarup17-Sep-06 21:26
Jakob Farian Krarup17-Sep-06 21:26 
GeneralRe: Deleting a file Pin
saqib8217-Sep-06 20:51
saqib8217-Sep-06 20:51 
GeneralRe: Deleting a file Pin
Jakob Farian Krarup17-Sep-06 21:27
Jakob Farian Krarup17-Sep-06 21:27 
QuestionMobile projects in C# Pin
yousafzai17-Sep-06 19:17
yousafzai17-Sep-06 19:17 
AnswerRe: Mobile projects in C# Pin
Jakob Farian Krarup17-Sep-06 19:34
Jakob Farian Krarup17-Sep-06 19:34 
QuestionFile Transfer Pin
Madhumathiid17-Sep-06 18:45
Madhumathiid17-Sep-06 18:45 
AnswerRe: File Transfer Pin
Jakob Farian Krarup17-Sep-06 19:25
Jakob Farian Krarup17-Sep-06 19:25 
QuestionXML parsing in c# Pin
aruna_koride17-Sep-06 17:07
aruna_koride17-Sep-06 17:07 
AnswerRe: XML parsing in c# Pin
Bob Nadler18-Sep-06 17:30
Bob Nadler18-Sep-06 17:30 
QuestionRe: XML parsing in c# Pin
aruna_koride18-Sep-06 18:32
aruna_koride18-Sep-06 18:32 
QuestionMainForm not here for working in Code? Pin
xenotronic00717-Sep-06 15:38
xenotronic00717-Sep-06 15:38 
AnswerRe: MainForm not here for working in Code? Pin
Christian Graus17-Sep-06 15:48
protectorChristian Graus17-Sep-06 15:48 
GeneralRe: MainForm not here for working in Code? Pin
xenotronic00718-Sep-06 13:25
xenotronic00718-Sep-06 13:25 
GeneralRe: MainForm not here for working in Code? Pin
Christian Graus18-Sep-06 13:45
protectorChristian Graus18-Sep-06 13:45 
QuestionAdd LinkLabel to panal Pin
Muller217-Sep-06 7:38
Muller217-Sep-06 7:38 
AnswerRe: Add LinkLabel to panal Pin
Stefan Troschuetz17-Sep-06 8:18
Stefan Troschuetz17-Sep-06 8:18 

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.