Creates or opens a file for writing and writes text to it. : Text File Read Write « File Stream « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » File Stream » Text File Read WriteScreenshots 
Creates or opens a file for writing and writes text to it.
     
// 
//   SubSonic - http://subsonicproject.com
// 
//   The contents of this file are subject to the New BSD
//   License (the "License"); you may not use this file
//   except in compliance with the License. You may obtain a copy of
//   the License at http://www.opensource.org/licenses/bsd-license.php
//  
//   Software distributed under the License is distributed on an 
//   "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
//   implied. See the License for the specific language governing
//   rights and limitations under the License.
// 
using System.IO;
using System.Net;

namespace MVCPets.Extensions
{
  public static class IO
  {
    /// <summary>
    /// Creates or opens a file for writing and writes text to it.
    /// </summary>
    /// <param name="absolutePath">The complete file path to write to.</param>
    /// <param name="fileText">A String containing text to be written to the file.</param>
    public static void CreateToFile(this string fileText, string absolutePath)
    {
      using (StreamWriter sw = File.CreateText(absolutePath))
        sw.Write(fileText);
    }

  }
}

   
    
    
    
    
  
Related examples in the same category
1.Read and Write a Text File
2.Read text file line by line
3.Read ASCII string from byte bufferRead ASCII string from byte buffer
4.Reads and displays bytes until end-of-fileReads and displays bytes until end-of-file
5.Write string to a text file
6.Read whole text file to the end
7.Read text file line by line with exception catch
8.Text file Write with format and write boolean value to a text file
9.Action Text Reader Line
10.Open and Append to a Log File
11.Read and Write to a Newly Created Data File
12.Read Text from a File
13.Read text file with File.OpenText
14.Write Text to a File
15.Read a text file and obtain it's contents.
16.Reads text from a file.
17.Saves the text to a file.
18.Read Text File From Ressource
19.Create a large file of 100 lines to upload
20.Returns the raw number of the current line count.
21.Returns the zero-based line number where source appears in target.
22.Returns the number of lines appearing in target where a line is counted as a '\n'
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.