Click here to Skip to main content
16,012,025 members
Home / Discussions / C#
   

C#

 
QuestionDelegate for a field function Pin
manustone6-Nov-07 0:45
manustone6-Nov-07 0:45 
AnswerRe: Delegate for a field function Pin
TJoe6-Nov-07 1:42
TJoe6-Nov-07 1:42 
GeneralRe: Delegate for a field function Pin
manustone6-Nov-07 2:23
manustone6-Nov-07 2:23 
AnswerRe: Delegate for a field function Pin
MarkusStr6-Nov-07 1:46
MarkusStr6-Nov-07 1:46 
GeneralRe: Delegate for a field function Pin
manustone6-Nov-07 2:24
manustone6-Nov-07 2:24 
Questiontemporary file in C# Pin
kaminem6-Nov-07 0:45
kaminem6-Nov-07 0:45 
AnswerRe: temporary file in C# Pin
Vasudevan Deepak Kumar6-Nov-07 0:47
Vasudevan Deepak Kumar6-Nov-07 0:47 
AnswerRe: temporary file in C# Pin
Pete O'Hanlon6-Nov-07 2:56
mvePete O'Hanlon6-Nov-07 2:56 
I find that the following code can be helpful. This class creates a temporary file that you can use, which is removed once you dispose the instantiating class.
;  /// <summary>
  /// Create a temporary file. The file will be removed as soon as 
  /// the instance of this class is disposed.
  /// </summary>
  public class TempFile : IDisposable
  {
    private string _fileName;
    private bool disposed = false;
    /// <summary>
    /// Instantiate a new instance of <see cref="TempFile"/>.
    /// </summary>
    public TempFile()
    {
      _fileName = Path.GetTempFileName();
    }

    /// <summary>
    /// Get the temporary file name.
    /// </summary>
    public string FileName
    {
      get { return _fileName; }
    }

    #region IDisposable Members
    /// <summary>
    /// Dispose of the temporary file.
    /// </summary>
    public void Dispose()
    {
      Dispose(true);
    }
    protected void Dispose(bool dispose)
    {
      if (dispose && !disposed)
      {
        if (File.Exists(_fileName))
        {
          try
          {
            File.Delete(_fileName);
          }
          catch (IOException ex)
          {
            Trace.WriteLine(string.Format("Unable to remove temporary file because of {0}", 
              ex.Message));
          }
        }
        disposed = true;
        GC.SuppressFinalize(this);
      }
    }
    #endregion
  }
using (TempFile tempFile = new TempFile())
{
filename = tempFile.FileName;
using (FileStream fs = new FileStream(tempFile.FileName, FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("Write to temp.");
}
fs.Close();
}
Console.WriteLine("The size of {0} is {1} bytes", tempFile.FileName,
new FileInfo(tempFile.FileName).Length);
}

Deja View - the feeling that you've seen this post before.

AnswerRe: temporary file in C# Pin
Le centriste6-Nov-07 3:53
Le centriste6-Nov-07 3:53 
QuestionCan any one please help me how to implement paging with datalist in C#,ASP.Net Pin
clife5375-Nov-07 23:28
clife5375-Nov-07 23:28 
AnswerRe: Can any one please help me how to implement paging with datalist in C#,ASP.Net Pin
Sun Rays5-Nov-07 23:45
Sun Rays5-Nov-07 23:45 
GeneralRe: Can any one please help me how to implement paging with datalist in C#,ASP.Net Pin
clife5375-Nov-07 23:47
clife5375-Nov-07 23:47 
GeneralRe: Can any one please help me how to implement paging with datalist in C#,ASP.Net Pin
Christian Graus5-Nov-07 23:50
protectorChristian Graus5-Nov-07 23:50 
GeneralRe: Can any one please help me how to implement paging with datalist in C#,ASP.Net Pin
Pete O'Hanlon6-Nov-07 1:06
mvePete O'Hanlon6-Nov-07 1:06 
GeneralRe: Can any one please help me how to implement paging with datalist in C#,ASP.Net Pin
Sun Rays5-Nov-07 23:59
Sun Rays5-Nov-07 23:59 
QuestionForm At Design time Pin
SVb.net5-Nov-07 23:18
SVb.net5-Nov-07 23:18 
AnswerRe: Form At Design time Pin
Christian Graus5-Nov-07 23:22
protectorChristian Graus5-Nov-07 23:22 
AnswerRe: Form At Design time Pin
Giorgi Dalakishvili5-Nov-07 23:25
mentorGiorgi Dalakishvili5-Nov-07 23:25 
GeneralRe: Form At Design time Pin
SVb.net6-Nov-07 1:28
SVb.net6-Nov-07 1:28 
GeneralRe: Form At Design time Pin
Giorgi Dalakishvili6-Nov-07 5:56
mentorGiorgi Dalakishvili6-Nov-07 5:56 
QuestionChange CSS values with C# Pin
sidneyk5-Nov-07 23:16
sidneyk5-Nov-07 23:16 
AnswerRe: Change CSS values with C# Pin
benjymous6-Nov-07 0:01
benjymous6-Nov-07 0:01 
AnswerRe: Change CSS values with C# Pin
Sun Rays6-Nov-07 0:12
Sun Rays6-Nov-07 0:12 
QuestionWWF Machine state model Pin
Yoyosch5-Nov-07 22:40
Yoyosch5-Nov-07 22:40 
AnswerRe: WWF Machine state model Pin
TJoe6-Nov-07 4:25
TJoe6-Nov-07 4:25 

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.